Software Engineering Architecture Lab

Level 6: Domain-Driven Design

Model a complex business domain in code, and draw boundaries where the language changes. Level 6 of 11: 8 lessons on domain-driven design. Based on DDD.

Outcome: Model a complex business domain in code, and draw boundaries where the language changes.

Orders, subscriptions, invoices, shipments and refunds — ShopFlow’s domain is now the hard part. Tactical DDD gives us building blocks; strategic DDD tells us where the boundaries go.

The pressure on ShopFlow: “Customer” means five different things to five teams, and the model is a tangle.

Lessons in level 6

  1. Ubiquitous Language: Code That Speaks the Business — One shared vocabulary between experts and code, per boundary.
  2. Entities vs Value Objects — Identity vs value: why Address and Money should not have ids.
  3. Aggregates: Consistency Boundaries That Protect Invariants — Group objects that must change together, and guard them behind one root.
  4. Domain Services vs Application Services — Where logic goes when it does not belong to a single entity.
  5. Domain Events: Things That Happened — Model important facts explicitly and let other parts react.
  6. Bounded Contexts: Where Words Keep One Meaning — A boundary around a part of the business where the same words mean the same thing.
  7. Context Maps: How Bounded Contexts Relate — Anti-corruption layers, shared kernels, customer/supplier, open host and more.
  8. Strategic Design: Core, Supporting & Generic Subdomains — Invest where you compete; buy or simplify the rest.

Source books

  • DDD — Eric Evans

Other levels