Domain Driven Design

Use when: model a complex domain with a shared language, bounded contexts, and clear aggregates.

kimtth 9768ea1 1.1 KB Updated

File contents

Goal: software whose structure mirrors the business domain.

Use for:

  • complex domains with rich rules and vocabulary
  • untangling a tangled model into clear boundaries
  • aligning code with how the business actually speaks

Workflow:

  1. Build a ubiquitous language with domain experts.
  2. Identify bounded contexts and their boundaries.
  3. Model aggregates that enforce invariants as a unit.
  4. Separate entities (identity) from value objects (equality by value).
  5. Keep domain logic in the model, not in services or controllers.
  6. Map context relationships explicitly.

Building blocks:

  • entities, value objects, and aggregates
  • domain events for cross-aggregate effects
  • repositories for aggregate persistence
  • anti-corruption layers between contexts

Rules:

  • one ubiquitous language per bounded context
  • aggregates protect their own invariants
  • do not leak domain logic into infrastructure
  • keep contexts decoupled; translate at the edges

kimtth/agent-skill-100-lines-or-less/tree/main/skills/domain-driven-design commit 9768ea1d68

Frequently asked questions

npx skillmds@latest add kimtth/domain-driven-design