Member-only story
Domain Driven Design
What is Anemic Domain Model and why it can be harmful?
Anemic Domain Model is a common approach in software development that many folks don’t even know they are using it including myself. If you are using Entity Framework, there is a chance you know this approach. But do you?

What is the Anemic Domain Model?
It is a Model which separates data and operation working with them from each other. In most of the time, your domain consists of two separated classes. One is the entity, which is holding data, the other is the stateless service, which operates with an entity.
Entity is usually represented with public properties. Setters and getters. Typical example of Entity Framework entity in the .NET application can look like this:
Stateless service, as the name suggests, is represented with stateless class, which means that it contains methods only and such methods should operate only with a related entity. Its Stateless Service can look like this:
You may use more than one service class to operates with an entity. This example serves to demonstrate the idea behind the Anemic Domain Model.
Why is Anemic Domain Model harmful?
One could say that the Anemic Domain Model is not going along with Object-Oriented Design. The separation of logic into other class is just not correct in OOD approach. But it is not the primary reason why Anemic Domain Model is harmful. Having a pure OOD is not the goal in and of itself. We need to consider more fundamental reasons. There are three…