Ehsan Ghanbari

Experience, DotNet, Solutions

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, a 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 the 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

About Me

Ehsan Ghanbari

Hi! my name is Ehsan. I'm a developer, passionate technologist, and fan of clean code. I'm interested in enterprise and large-scale applications architecture and design patterns and I'm spending a lot of my time on architecture subject. Since 2008, I've been as a developer for companies and organizations and I've been focusing on Microsoft ecosystem all the time. During the&nb Read More

Post Tags
Pending Blog Posts
Strategic design
Factory Pattern
time out pattern in ajax
Selectors in Jquery
Peridic pattern
How to use PagedList In MVC
Redis as a cache server
Domain driven design VS model driven architecture
How to query over Icollection<> of a type with linq
What's the DDD-lite?
comments powered by Disqus