Geeks With Blogs
Blog Moved to Blog Moved to
There have been a lot of things lately that have been grabbing my attention with regards to Domain Driven Design and definitely some things I've missed.  It's all about my continuous learning about this subject that's near and dear to my heart.  Back in 2006, Ramnivas Laddad gave a presentation entitled Domain Driven Design with AOP and DI.  In this talk, he asserts that you cannot implement Domain Driven Design without the help of Aspect Oriented Programming and Dependency Injection

He states several problems with DDD as designed by many people.  He contends that our POCOs became only mere data collections when they should have not only the data, but the behaviors as well.  This in turn makes the domain model weak and most of the reliance came upon the service

So, how do we get around those issues?  He contends that in order to have a rich domain object, you need collaboration with other objects.  This means that you need a web of objects that mirrors the domain model.  You also need DI at the domain level, and that using configuration nor factories may suffice for this, hence the DI needed.  Also, crosscutting domain concerns are not mapped well using objects alone.  AOP is needed to address these concerns.  This will cover the tracing, auditing, transaction management and so on.

An indiciation you've already run into that is that your objects have a dependency on transaction management, and that all your business layer logic is exclusively in the service layer.  So, the session really covers that fine grained DI with AOP can help your domain objects gain back some of their smartness and that AOP can keep your domain clean as well.  This session is well worth a listen whether you agree or disagree.

I agree with the assertion that AOP can keep the domain model clean and it's a high priority on my list to do so.  For those looking at AOP, there are a few .NET frameworks worth looking at:
I can honestly say I've only looked at PostSharp and Spring.NET for this, so I can't really speak for the others  I've found PostSharp quite easy to use with compile and runtime weaving.  I wish it were more native to the .NET framework as a whole, and I think it may be coming if Microsoft Research releases Phoenix.  A download is available on this site for you to give it a go. 

Also, Ramnivas Laddad posted a session on Leveraging Annotation with AOP that is also well worth a watch.

Until next time, Develop, mentor and inspire! Posted on Sunday, January 13, 2008 11:23 PM Domain Driven Design | Back to top

Comments on this post: Domain Driven Design Cannot be Adequately Implemented without DI and AOP

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Matthew Podwysocki | Powered by: