EvilRob.org -> Weblog

Sysadmin Field Notes

The Law of Demeter in Domain Driven Design

July 31, 2007

Here's a very nice explanation of the Law of Demeter.

In thinking about this and its relation with Domain Driven Design makes me think of something that initially seems like a good guideline. You should watch very carefully for "Demeter" violations between aggregates, but within an aggregate they are probably less dangerous.

Focusing on custom messages between your aggregates in DDD would seem to be a big help in two ways. First by helping root out your aggregate boundaries during design, by looking for high level behavior conversations that might exist. Second by helping to break data dependencies between aggregates that might otherwise be very tempting to introduce when trying to persist that group of objects.

I think paying more attention to obeying the Law of Demeter between aggregates and worrying about it less within the group might be a good way of keeping balance between creating custom messages for everything and re-using data attributes inappropriate in a way that makes code fragile.

Posted by rmeyer at 12:10 PM

This is Rob Meyer's weblog, a weblog focused on software development and system administration based on 10 years of experience. Want to explore further? You can find out more me or see the rest of my website.

Wondering if I've written on something in particular? Try searching:

You might want to take a look at some of the more requested postings (as judged by incoming traffic):

Want more? Subscribe to this site or contact me at rob at big dis dot com.

See my writings on:


Powered by Movable Type | Technorati Profile