Should domain objects call service methods ?

18Feb08

Inevitably, every  few months someone over at DDD ( domain driven design ) mailing list seems to ask the question ..

“Should domain objects call service methods ?” .  There are few people who seem to think that domain model should be a pristine place where only rightyworthy  get to live (Classes have to earn this right by being an parallel to something  in real world) . And there are few others who believe in making concessions to make domain model richer and self contained , and if your domain code is never going to be packaged on its own and used outside of the application for which it was originally designed why make this artificial divide .

The pros and cons to such approach can be breifly summried as ,

Pros :

  1. Makes domain model richer by hiding underlying data retrival logic .

  Cons :

  1. Model objects aren’t serializable .
  2. May break transactional data access semantics in some cases .
  3. Calling Methods on Domain models involves overhead of data retrieval which may not be obvious if not documented.
  4. domain model should be “concerned” only with modeling the business domain.
  5. May contribute to “Knowledge leak” from domain objects into service laye

references :

  1.  http://blog.hibernate.org/cgi-bin/blosxom.cgi/2004/08/10#v3-filters
  2. http://www.almaer.com/blog/archives/000966.html
  3. Discussion on spring forum http://forum.springframework.org/archive/index.php/t-9874.html
Advertisements


No Responses Yet to “Should domain objects call service methods ?”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: