User Tools

Site Tools


anti-patterns:anemic_domain_model

Anemic Domain Model

Alternative Names

Context

Problem Statement

A Domain Model without behavior

Description

In a Domain Model the model classes are supposed to have behavior. All the domain logic (validations, calculations, business rules) should be implemented there. In an anemic domain model model classes are mere data containers and all the domain logic is implemented in the service layer. The service layer should normally just coordinate but when the domain model is anemic, it effectively does everything and the domain model is devoid of any behavior. In that sense it's a procedural design in an object-oriented language.

Causes

Some frameworks like the old J2EE entity beans encourage having anemic model classes which just have getters and setters. Furthermore consistency and old habits often lead to anemic models.

Origin

Martin Fowler: Bliki

Disadvantages

Advantages

Refactorings

Anti-Pattern Collections

Examples

Example 1:

Description Status

Further Reading

Discussion

Discuss this wiki article and the anti-pattern on the corresponding talk page.

anti-patterns/anemic_domain_model.txt · Last modified: 2017-05-29 11:12 by christian