Difference between Anemic Domain Model and Rich domain model

There are lots of differences between these to approach. Anemic model is an anti-pattern introduced by martin fowler to encourage developers to duplicate code!  Based on the main idea behind DDD, if you have ubiquitous language then you can have domain model Anemic domain model is the use of a software domain model where the domain objects contain little or no business logic. in a Rich Domain Model behavior is included in the domain object while in Anemic Domain Model behavior is implemented in separate classes.

At some point in the design of the software it is decided to implement certain pieces of logic for a domain entity outside of that domain entity.  This may be as a result of an explicit design decision or some pieces of logic just cannot be implemented in the domain entity because it is a persistent class and has no internal references to external services. 

The fundamental horror anemic model is that it's so contrary to the basic idea of object-oriented designing; which is to combine data and process them together. anemic objects are not real objects, and it's something different from object-oriented design. In anemic model, business logic is typically implemented in separate classes which transform the state of the domain objects. "A domain model in problem solving and of all the topics related to a certain problem. It describes the various entities, their attributes, roles, and relationships, plus the constraints that govern the problem domain. The domain model is created in order to represent the vocabulary and key concepts of the domain problem." ~ wikipedia


Tags: Architecture Design Pattern


comments powered by Disqus