Domain Driven Design
A strategy aimed at improving the quality of software by aligning it more closely with the business needs it serves.
-> Bringing Devs and Domain Experts (Business People) closer together
Strategic Design
Higher Level
Is about the Problem Space
- Value:
- What is the value of our solution
- Knowledge Discovery
- Who are our Domain Experts
- Event Storming
- Put events on a board (i.e. stick nodes)
- e.g. Create Cart, Add to Cart, Remove Product, ...
- Put events on a board (i.e. stick nodes)
- Communication
- Improve Communication with Ubiquitous Language
- Business and Devs use the same words for the same thing
- Improve Communication with Ubiquitous Language
- Domain Analysis
- Cluster events from the Event Storming to form subdomains
- Core Subdomains
- (most of the) Business Value
- Supporting Subdomains
- Generic Subdomains
- Can also be outsource or be handled with 3rd party software
- Core Subdomains
- Cluster events from the Event Storming to form subdomains
Event Storming
- Devs, Business experts, PO, ... put Post-Its on a board
- Find Events and put it on the board
- Cart Created
- Product Added
- Find Actor and Commands for Events (one Command can lead to multiple Events)
- Customer -> Select First Product -> Cart Created
- Customer -> Adds Product -> Product Added
- Policies find rules or constraints for the Events
- Customer -> Select First Product -> Check Brand Minimum Rules -> Cart Created
- Customer -> Adds Product -> Check Brand Minimum Rules -> Product Added
- Find Hotspots (something that is vulnerable and can go wrong) and map to Policies
- Customer -> Select First Product -> Check Brand Minimum Rules [External API Failure] -> Cart Created
- Customer -> Adds Product -> Check Brand Minimum Rules [External API Failure] -> Product Added
- Put everything in a sequence (might also go in parallel)
- Customer -> Select First Product -> Check Brand Minimum Rules [External API Failure] -> Cart Created
- Customer -> Adds Product -> Check Brand Minimum Rules [External API Failure] -> Product Added
- Come up with an aggregate
- Cart (Aggregate)
- Might contain Entities such as Cart and Product
- Cart (Aggregate)
- ...
Tactical Design
Lower level (closer to code)
Is about the Solution Space
- Bounded Context
- Entity
- Has an Id
- Mutable
- May span over multiple Bounded Contexts
- Value Objects
- No Id (its defined by its value)
- Immutable
- Basic building blocks of Entities
- Aggregates
- Cluster Entities
- One root Entity
- (usually) bound to a transaction scope
- Domain Events
- Facilitate asynx messaging between Bounded Contexts
- Domain & Application Services
- No state
- Application wide services (e.g. Auth)
- Domain services (e.g. Create Account)