Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'POCO' definition

Tags:

class

poco

People also ask

Is Poco a real word?

'Poco' is used to talk about amounts. It works either as an adverb or an adjective of quantity and means 'little', 'few' or 'a little bit of'.

Is Poco an English word?

Definition of poco in the English dictionary The definition of poco in the dictionary is a little; to a small degree.

What does a Poco Poco mean?

Definition of poco a poco : little by little : gradually —used as a direction in music.

Where does the word Poco come from?

poco (adv.) in musical directions, "a little, slightly," 1724, from Italian poco, from Latin paucus "few, little" (source also of French peu), from PIE *pau-ko-, suffixed form of root *pau- (1) "few, little."


"Plain Old C# Object"

Just a normal class, no attributes describing infrastructure concerns or other responsibilities that your domain objects shouldn't have.

EDIT - as other answers have stated, it is technically "Plain Old CLR Object" but I, like David Arno comments, prefer "Plain Old Class Object" to avoid ties to specific languages or technologies.

TO CLARIFY: In other words, they don’t derive from some special base class, nor do they return any special types for their properties.

See below for an example of each.

Example of a POCO:

public class Person
{
    public string Name { get; set; }

    public int Age { get; set; }
}

Example of something that isn’t a POCO:

public class PersonComponent : System.ComponentModel.Component
{
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    public string Name { get; set; }

    public int Age { get; set; }
}

The example above both inherits from a special class to give it additional behavior as well as uses a custom attribute to change behavior… the same properties exist on both classes, but one is not just a plain old object anymore.


Most people have said it - Plain Old CLR Object (as opposed to the earlier POJO - Plain Old Java Object)

The POJO one came out of EJB, which required you to inherit from a specific parent class for things like value objects (what you get back from a query in an ORM or similar), so if you ever wanted to move from EJB (eg to Spring), you were stuffed.

POJO's are just classes which dont force inheritance or any attribute markup to make them "work" in whatever framework you are using.

POCO's are the same, except in .NET.

Generally it'll be used around ORM's - older (and some current ones) require you to inherit from a specific base class, which ties you to that product. Newer ones dont (nhibernate being the variant I know) - you just make a class, register it with the ORM, and you are off. Much easier.


I may be wrong about this.. but anyways, I think POCO is Plain Old Class CLR Object and it comes from POJO plain old Java Object. A POCO is a class that holds data and has no behaviours.

Here is an example written in C#:

class Fruit 
{
    public Fruit() { }

    public Fruit(string name, double weight, int quantity) 
    {
        Name = name;
        Weight = weight;
        Quantity = quantity;
    }

    public string Name { get; set; }
    public double Weight { get; set; }
    public int Quantity { get; set; }

    public override string ToString() 
    {
        return $"{Name.ToUpper()} ({Weight}oz): {Quantity}";
    }
}

POCO stands for "Plain Old CLR Object".


In .NET a POCO is a 'Plain old CLR Object'. It is not a 'Plain old C# object'...


To add the the other answers, the POxx terms all appear to stem from POTS (Plain old telephone services).

The POX, used to define simple (plain old) XML, rather than the complex multi-layered stuff associated with REST, SOAP etc, was a useful, and vaguely amusing, term. PO(insert language of choice)O terms have rather worn the joke thin.


In Java land typically "PO" means "plain old". The rest can be tricky, so I'm guessing that your example (in the context of Java) is "plain old class object".

some other examples

  • POJO (plain old java object)
  • POJI (plain old java interface)