12

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?

Community
  • 1
  • 1
user496949
  • 83,087
  • 147
  • 309
  • 426
  • 1
    Where did you learn who proposed them, but not what they *mean*? Oh, and it was [Martin Fowler](http://en.wikipedia.org/wiki/Martin_Fowler) who proposed those names. – Greg Hewgill Nov 12 '10 at 01:35
  • It means "Plain Old [Language] Object". Really, you can trivially search and discover this answer and more details for yourself. – Noon Silk Nov 12 '10 at 01:36

3 Answers3

23

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[...]

Pang
  • 9,564
  • 146
  • 81
  • 122
OscarRyz
  • 196,001
  • 113
  • 385
  • 569
15

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);
        }
    }
}
Rex M
  • 142,167
  • 33
  • 283
  • 313
4

POCO stands for Plain Old CLR Object and POJO for Plain Old Java Object.

Alex McBride
  • 6,881
  • 3
  • 29
  • 30