An anemic domain model is a collection of data objects with little or no business behavior. Rules that belong with the data are scattered elsewhere, often in a fat controller. The result: objects cannot protect their own state, and behavior is less cohesive. section 4.7.2
Listing 4.8 Before (The Symptom)
class Order { #A
constructor() {
this.id = 0;
this.total = 0.0; #B
this.customerEmail = ""; #B
this.items = []; #B
}
}The Order class stores an ID, total, customer email, and items, but has no behavior to validate or protect them; another class could set its total to -100. section 4.7.2
Keep core business rules with the domain model so they can be tested in isolation. Put orchestration in the application layer, HTTP concerns in presentation, and database or email concerns in infrastructure. A rich domain model plus automated architectural checks helps keep those boundaries from eroding. section 4.7.4
