Coding StandardsDomain Modeling
Domain Modeling
How domain state and behaviour should be shaped so invalid states cannot exist.
These standards govern how a domain concept becomes a type: where behaviour lives, how invariants are protected, and how to avoid the anemic, flag-driven models that push logic into services and callers instead of the type itself. Apply them whenever defining or reworking an entity, aggregate, or value object.
- Avoid Anemic Domain Models
- Avoid the Combinatorial Explosion Trap From Anemic Models
- Build External API Queries With a Lightweight Query Specification
- Clean Architecture Use Cases
- Eliminate Data Clumps with Value Objects
- Enforce Invariants in Constructors via Factory Methods
- Express Business Rules as Composable, Injectable Rule Objects
- Immutable Domain Models
- Model EF Core Aggregates as Immutable Types
- Push Type-Specific Branching Into Polymorphic Methods
- Refactor Anemic State-Bag Models
- Replace Boolean Status Flags With Closed Type Hierarchies
- Use Records as Functional Values, Not Objects With Hidden State