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?
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?
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);
}
}
}
POCO stands for Plain Old CLR Object and POJO for Plain Old Java Object.