Back to basics: Rich model vs Anemic model

Rich vs anemic models

Rich and anemic patterns are two concepts about the representation of your models and entities. If you are working with MVC frameworks (Model-View-Controller), you should be already aware of what’s a model or an entity.

These two concepts help you structure your application depending on whether the domain logic (a.k.a “business logic related to database and storage”) should be located in your entities or in external components.

In a few words, “Rich” is about putting all your logic in your entities as much as possible (“rich” setters, events, business logic, etc.), and “Anemic” is more about having “empty” or “blank” classes that do almost nothing except mapping the different properties and using simple getters and setters (heard about fluent setters ?).

Both represent advantages and drawbacks, even if this presentation is more in favor of the Rich pattern, but it depends on both opinions and application structure :)

Training Rich-model-pattern