Friday, March 05, 2010

Data Object and Service Object Design

Data Objects hold data. They do *not* operate on the data (like save, delete etc…).

Service Objects operate on the data held by Data Objects.

 

Data Object design is more real life driven. If there is a “Is a” relationship between two entities in real world, the model objects have a “Is a” relationship. For example a Dog “Is a” Animal.

 

Service Objects design is more application architecture driven. For example if a reusable functional logic should be achieved through aggregation or composition or a utility class (read post titled “Don’t extend to extend functionality. Extend to only override functionality”).

No comments: