Possible Duplicate:
What does the term Plain Old Java Object(POJO) exactly mean?
I know those are recent concepts proposed by Mark Fowler. can anyone explain what the purpose of POJO or POCO and their usage?
POCO stands for Plain Old CLR Object and POJO for Plain Old Java Object.
In software engineering, a plain old CLR object, or plain old class object (POCO) is a simple object created in the . NET Common Language Runtime (CLR) that is unencumbered by inheritance or attributes.
In software engineering, a plain old Java object (POJO) is an ordinary Java object, not bound by any special restriction.
POCO stands for Plain Old CLR Object, or Plain Old C# Object. It's basically the . Net version of a POJO, Plain Old Java Object. A POCO is your Business Object. It has data, validation, and any other business logic that you want to put in there.
P lain O ld ( J ava,/ C LR ) O bject
It's just a fancy name for a very basic class structure1.
[...]We wondered why people were so against using regular objects in their systems and concluded that it was because simple objects lacked a fancy name. So we gave them one[...]
It stands for Plain Old [Java|CLR] Object, and it means pretty much what it says - a simple object that doesn't require any significant "guts" to make it work. The idea is in contrast with very dependent objects that have a hard time being (or can't be) instantiated and manipulated on their own - they require other services, drivers, provider instances, etc. to also be present.
Here's an example of a c# POCO:
public class Customer
{
public string Name { get; set; }
}
And here's the hypothetical innards of a hypothetical non-POCO:
public sealed class Customer
{
//can only be created by a db service layer
internal Customer(IDbContext databaseContext)
{
}
[EntityMapping("Name")]
public string Name
{
get
{
return context.HydrateValue(this, "Name");
}
set
{
InternalNotifyRevision("Name", value);
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With