Archive for the ‘Spring’ Category

Jan
30

How Anaemic Domain Models Cause Bad Software

Using an anaemic domain model is often considered an anti-pattern.  The reason for this is that it encourages coders to duplicate code needlessly.  This is going to be a fairly short (and fairly trivial) post explaining one of the mechanisms by which this occurs (with an example).  The mechanism can be avoided with careful planning and strict coding discipline but it is quite a lot easier to apply good encapsulation.  The difficulty with avoiding the pit falls of an anaemic domain increases exponentially as more team members work on the project.
None of this will be new for anybody with a moderate understanding of OOP, but it is interesting to see how a small number of fairly innocent steps can lead to a real mess.

(more…)

Dec
31

Domain Driven Design with Spring and Hibernate

I’ve been playing around with Domain Driven Design (DDD) and trying to write a small web application without implementing an anemic domain model.  I have found that it is more difficult than it ought to be and I want to share some of my experiences.

An anaemic domain is something that happens in an enterprise application when your domain objects don’t really contain any real logic.  Instead the logic nearly all resides in a secondary “service” component.  This is an example of badly encapsulated code and will lead to messy, difficult to maintain applications.

(more…)