Symptom
A class that holds fields with getters and setters but no behavior — and consumers do all the operations on it externally.
Goal
Behavior that belongs with the data lives on the class; the class becomes a real domain object.
Smellier version
class Address { street; city; zip; }
function format(a) {
return `${a.street}, ${a.city} ${a.zip}`;
}Fresher versionclass Address {
format() {
return `${this.street}, ${this.city} ${this.zip}`;
}
}Savings
Invariants are enforceable; consumers write less domain plumbing; tests target the class itself.
Note
Domain logic gets scattered to consumers; the class's data invariants aren't enforced; encapsulation is theater.