Domain-driven design

Tackling Complexity in the Heart of Software

What is domain-driven design?

Problem space
Domain Business problem to be addressed
Sub-domain Smaller part of the domain
Solution space
Domain model Abstraction of a business problem
Bounded context Delimits the domain model

The goal of a domain-driven design is an alignment between the domain and the software.

How do we identify subdomains?

Types of subdomains

  1. Core domain
  2. Supporting subdomain
  3. Generic subdomain

Core domain

Supporting subdomain

Generic subdomain

Domain-driven comprises …

  1. Strategic design:
    • Ubiquitous language
    • Bounded context
    • Context map
    • Continuous integration
  2. Tactical design:
    • Entity
    • Value object
    • Aggregate
    • Domain event
    • Service
    • Repository
    • Factory

Strategic design

Ubiquitous language

A domain specific term can have multiple meanings.
Understanding the meaning of the word is dependent upon the context.

Bounded context

Context map

Partnership

Shared kernel

Customer-supplier

Conformist

Anticorruption layer

Open host service

Published language

Separate ways

Tactical design

Aggregate, root, & entity

Entity

Value object

Aggregate

Four rules of aggregate design

  1. Protect business invariants inside aggregate boundaries
  2. Design small aggregates
  3. Reference other aggregates by identity only
  4. Update referenced aggregate using eventual consistency

Domain event

Service

Repository

Factory

Further reading