Instead of calling them POCO, I prefer to call them the persistence of uninformed objects.
Because their work is simple, they do not need to worry about what they are used for or how they are used.
Personally, I think POCO is another buzzword (like Web 2.0 - don't make me start with this) for an open class with simple properties.
I have always used this type of object to store in a business state.
The main advantage of POCO is really observed when you start using things like repository template, ORM and dependency injection.
In other words, you can create an ORM (let's say EF) that distracts data from somewhere (db, web service, etc.), and then project that data into objects (POCO).
These objects can be transferred further on the application stack to the service level, and then to the web level.
Then, if one day you decide to switch to nHibernate, you donβt have to touch your POCO at all, the only thing you need to change is ORM.
Therefore, the term "stubborn ignorance" - they do not care what they are used for or how they are used.
So, to summarize, pro's:
- Allows a simple data storage mechanism, simplifies serialization / passing through layers
- Goes hand in hand with Dependency injection, repository template and ORM. Flexibility.
- Minimized complexity and dependencies on other layers. (a higher level only cares about POCO, POCO does not care about anything). Loose connection
- Simple testability (circumcision is not required for domain testing).
Hope this helps.
RPM1984 Aug 2 '10 at 23:46 2010-08-02 23:46
source share