Domain-Driven Design & Clean Architecture

on the example of The Three Little Pigs

Context is important

url: sli.do

code: #geecon2022

DDD

Strategic

Tactical

Strategic DDD

supporting subdomain generic subdomain
supporting subdomain core domain supporting subdomain
generic subdomain generic subdomain

Bounded Context


Fairy tales

Mother
House
Wolf

How to plan all of this?

EventStorming!

  • Golden rule: events (verbs, past tense), NOT data structures (nouns)
  • Big Picture ES - to discover domains etc.
  • Process-Level ES - to discover Bounded Contexts
  • Design-Level ES - for a tactical DDD within a BC
  • Commands (change the system's state) & queries (views)

domainlanguage.com/ddd/whirlpool

DDD

Strategic

Tactical

Tactical DDD





Specification, Policy

Tactical DDD - code

What aggregate for The Three Little Pigs?

Concepts

  • House building: straw, wood, bricks
  • Wolf blowing house down => pig escaping to the neighbor
  • Wolf resigning after 2 failures
  • Pigs learning from the mistakes and improve
  • Skipping:
    • Mother of the pigs
    • Chimney climbing
    • Eating the pigs

So what?

Big Picture

Design-Level

Clean Architecture

User Story/Command

  • As a user, I want to get to know a fairy tale, so that I can tell it to others
  • As a pig, I want to build a house, so that it fulfills my requirements
    • Documenting & storing the information
  • As a pig, I want to visit my neighbor
  • As a pig, I want to share my knowledge with my roommates
  • As a wolf, I want to blow the pig's house down, so that I can catch the pig
    • Registry - this house is hard to destroy

Thanks!