What is the Difference Between a DTO and a POCO?

 

SO: POCO vs DTO

 

As Wyatt said, POCO and POJO in no way implies no methods. I think that stems from not knowing what non-POCO and non-POJO is.

 

First versions of ORM technologies weren’t POCO and POJO simply because it required the entities to inherit some base class from the framework itself. In case of Java, Entity Beans .In case of Entity Framework, POCO wasn’t possible in very first version and each entity was required to inherit Entity base class.

 

This requirement created dependence of your data model on the persistence technology, which makes lots of things hard or impossible. Things like unit testing the model requires mocking the bean/entity framework which proved to be practically impossible. You also cannot use the model with different persistence technology or you cannot use the model in different context, like in mobile environment.

 

So your assumption that POCO is about non-existence of methods is wrong. POCO is about being able to use the model in separation from it’s persistence technology.

 

What you are talking about is probably closes to Anemic Domain Model vs proper domain model.

 

 

Introduction to POCO View Models

 

MVVM using POCOs with .NET 4.0 and the DynamicViewModel Class

 

DynamicViewModel: MVVM using POCOs with .NET 4.0

 

View Models: POCOs versus DependencyObjects