Skip to main content

Domain Model Pattern

Learn Domain Model Pattern (Enterprise Design Patterns, Enterprise Design Patterns) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

What is the Domain Model Pattern? A Domain Model is an object model of the business domain that combines BOTH data AND behavior in the same objects - a BankAccount class doesn't just hold a balance field, it also has a withdraw() method that enforces the business rule (can't go below zero) directly on itself. Domain Model vs Anemic Domain Model An anemic domain model (an anti-pattern, not this pattern) has classes that are just data bags (getters/setters only), with ALL logic living in separate Service classes. A true Domain Model pushes behavior that belongs to the data onto the data's own...

More lessons in Enterprise Design Patterns