Updated Devoxx edition of my Extreme DDD Modelling Pattern that I presented at Devoxx Poland in June 2024.
Modelling a complex business domain, without trade offs and being aggressive on the Domain-Driven Design principles. Where can it lead?
Size: 105.45 MB
Language: en
Added: Jun 24, 2024
Slides: 43 pages
Slide Content
Extreme DDD
Modelling
patterns
@ziobrando
2024
Disclaimer
In Domain-Driven Design since the early days
In love with CQRS/ES and EventStorming
Enjoying modelling without trade-offs
Running My own company
Unusual freedom
Eating my own gourmet dogfood
The account that wasn’t
Quick intro
Context
Simple Treasury Module: we need to know the
available liquidity in different accounts
Multiple account types, no integrations via API (we’re
too small/lazy/Poor)
So…
•We need an account.
name
currentBalance
Account
deposit
withdraw
Pick your poison
name
currentBalance
Account
deposit
withdraw
Incoherent
design
Someone
else’s model
bank
Not the
domain name
name
currentBalance
lastUpdatedOn
Account
registerSnapshot
trackOperation
name
currentBalance
lastUpdatedOn
AccountTracker
registerSnapshot
trackOperation
Consistent with
User’s Expectation
Coherent with
semantics
name
currentBalance
lastUpdatedOn
Account
registerSnapshot
trackOperation
name
currentBalance
lastUpdatedOn
AccountTracker
registerSnapshot
trackOperation
! Ubiquitous Language?
Account
Labels can make
you happy
Account
Danger Zone!
•Why did we pick the wrong model first?
•Kahneman’s System one?
•…There’s a little backdoor in our brain
that allows school examples to bypass
validation
•Including examples from speakers on a
stage
name
currentBalance
Account
deposit
withdraw
The Dictionary
Interlude
context
Long Lasting Project (3+ Years) in a large
organisation
Complex domain with a very specific jargon
Legacy core
Glossary built with the best intentions
Still trapped in special cases
The revelation
Photo by Joshua Earle on Unsplash
Every single term from
Marketing was crap!
I’ll follow you
everywhere my
beloved domain
expert!!
I have no clue
where I am going…
Not every information from
the “expert” is suitable to
become part of our model
Room Reservations
Some are assigned at purchase time
Some are assigned at departure time
Rooms can be sold with ancillary services
Upgrades are possible
Money can buy almost everything
Labels can make
you happy
All Inclusive
Bundle
Catalog Item
Not cool enough to
be mentioned by
marketing
Maybe we’re not selling
our inventory after all…
Maybe we’re always selling a bundle, which sometimes is simple
"
"
A Flat Dictionary can be a
force in the wrong
direction
# Make sure your Dictionary reflects your bounded contexts
Experts grown on legacy,
will guide you to rebuild
the legacy
Complex Software in the
small
Or: “how not to grow a Big Ball of Mud”
Bounded Context
•Limit of applicability of a
model
•Unit of language
consistency
•A single model tailored
around a specific purpose
Bounded Context
Good, but not actionable
Proxies to the rescue
•Every proxy has a
variable accuracy
•Unfortunately, most
of these proxies are
only visible in large
organisations
Bounded
Context
Limit of applicability
of a model
Team
Subdomain
Organization
Technology
Legacy
And of course…
In small Organizations…
•People, teams and department stop being relevant
•Everything is pulling towards a monolith
•All we’re left with is Purpose and Business Lines
Is this our Destiny?
In the small scale
•Single database -> Flat Namespace
•Single Project -> IDE doesn’t like Polysemic words
•Small Team -> The Mental Model naturally tends
towards a Flat Namespace
Designing to grow right
Possible Bounded Contexts
Trainings
Consulting
Planning
Marketing
Sales
Billing
Logistics
Webinars
Is Trainings a
Bounded
Context?
Finance
Our idea:
Separate on purpose
Logical separation only (easily reversible mistakes)
See what happens
Mixing is cheaper than
Splitting
Dogfood!
Business Lines first!
Books
Public Trainings
Private Trainings
Consulting
Sponsorships
Public Speaking
Software Delivery
Meetups
Events
Obvious in the large, but our responsibility in the small.
Then “Phases”
Books
Public Trainings
Private Trainings
Consulting
Sponsorships
Public Speaking
Software Delivery
Meetups
Events
Planning Sales Delivery BillingProduct Design Financial
Analysis
Strategy Marketing Inventory
Where are they coming from?
10 years of Orange Stickies on paper rolls?
Independent forces for change?
Some “standard” departments
Gut Feeling?
Perfection is not the goal
Then Purposes -> Models
Something is still missing, but …you got the point
Books
Public Trainings
Private Trainings
Consulting
Sponsorships
Public Speaking
Software Delivery
Meetups
Events
Planning Sales Delivery BillingProduct Design Financial
Analysis
Strategy Marketing Inventory
Date
Picking
Tracking
Value
Tickets and
discounts
Print on
Demand
Personal Availability
Engagement
Strategy
Deals
Pricing
Budget
Contracts &
Engagement
Partnerships
ForecastGlobal
Analysis
Billing
Billing
Scouting
Date
Picking
Content
design
Review
Logistics
Scouting
Courseware and
certificates
Newsletter &
social
Newsletter &
social
Content
Design
Format
Design
Bounded Contexts on a grid
$ Shapes and Distribution
Matters
% Commonalities are visible
% More precise names &
purposes
& Better project structure
in the IDE
We definitely need a map!
Books
Public Trainings
Private Trainings
Consulting
Sponsorships
Public Speaking
Software Delivery
Meetups
Events
Planning Sales Delivery BillingProduct Design Financial
Analysis
Strategy Marketing Inventory
Date
Picking
Tracking
Value
Tickets and
discounts
Print on
Demand
Personal Availability
Engagement
Strategy
Deals
Pricing
Budget
Contracts &
Engagement
Partnerships
ForecastGlobal
Analysis
Billing
Billing
Scouting
Date
Picking
Content
design
Review
Logistics
Scouting
Courseware and
certificates
Newsletter &
social
Newsletter &
social
Content
Design
Format
Design
On a single business line…
It’s a value-creation network!
Looks a lot like EventStorming &
Public Trainings
Planning Sales Delivery BillingProduct Design Financial
Analysis
Strategy Marketing Inventory
Tickets and
discounts
Deals
Pricing
Global
Analysis
Billing
Date
Picking
Logistics
Scouting
Courseware and
certificates
Newsletter &
social
Content
Design
Reservations
Yummy!
Modelling our own flow(s)
And being radical about it
The Draft-Executable-Tracking
Archetype
Draft Model Executable Tracking
Easy to change,
possibly partially
specified
Solid, running on read-
only data
Collecting or
visualizing
Validation
Different Models, very similar languages, different paradigms
Visual Grammar
Aggregate
Read
Model
Command
Value
Object?
PolicyEvent
Person
Unit of
transactional
consistency
Something that
happened: verb in
part tense
Command
Reactive logic:
“Whenever
(event) then
(command)
The information
needed to decide
Read
Model
External
System
A little more complex:
Design
Planning
Sales
Inventory
Logistics
Tracking
Training
Summary
Public
Event
Open
Event
Printables
Venue
Booking
Ticket
Sale
Purchase
Aggregate
Read
Model
A little more complex
Design
Planning
Sales
Inventory
Logistics
Tracking
Training
Summary
Public
Event
Ticket
Sale
Open
Event
Printables
Register
Attendee
Purchase
Ticket
Open
Sales
Schedule
Confirm
Cancel
Close
Sales
Cancel
Attendee
Session
Plan
Ticket
Plan
…other possible
Value Objects
Open
Registra
tions
(capacity)
Close
Registrations
Venue
Booking
Purchase
Policies to connect-1
Design
Planning
Sales
Inventory
Logistics
Tracking
Training
Summary
Public
Event
Ticket
Sale
Open
Event
Printables
Register
Attendee
Purchase
Ticket
Open
Sales
Schedule
Confirm
Cancel
Close
Sales
Cancel
Attendee
Session
Plan
Ticket
Plan
…
Public Training
Event
Coordination
Open
Registra
tions
(capacity)
Close
Registrations
Venue
Booking
Purchase
Policies to connect-2
Design
Planning
Sales
Inventory
Logistics
Tracking
Training
Summary
Public
Event
Ticket
Sale
Open
Event
Printables
Register
Attendee
Reserve
Ticket
Open
Sales
Schedule
Confirm
Cancel
Close
Sales
Cancel
Attendee
Session
Plan
Ticket
Plan
…
PTE
Policy
Open
Registra
tions
(capacity)
Close
Registrations
Registration
Policy
Ticket
Purchased Attendee
Registered
Courseware
Policy
One more!
Venue
Booking
Purchase
Ticket
Reservation
Policy
Purchase
Started
Purchase
Completed Assign
Ticket
Read Models to summarise
Design
Planning
Sales
Inventory
Logistics
Tracking
Training
Summary
Public
Event
Ticket
Sale
Open
Event
Printables
Register
Attendee
Purchase
Ticket
Open
Sales
Schedule
Confirm
Cancel
Close
Sales
Cancel
Attendee
Session
Plan
Ticket
Plan
…
PTE
Policy
Open
Registra
tions
(capacity)
Close
Registrations
Ticket
Purchased
Attendee
Registered
Event
Confirmed
Purchase
All good?
Naming pain
Design
Planning
Sales
Inventory
Logistics
Tracking
Training
Summary
Public
Event
Ticket
Sale
Open
Event
Printables
Register
Attendee
Purchase
Ticket
Open
Sales
Schedule
Confirm
Cancel
Close
Sales
Cancel
Attendee
Session
Plan
Ticket
Plan
…
Public Training
Event
Coordination
Policy
Open
Registra
tions
(capacity)
Close
Registrations
Ticket
Purchased
Attendee
Registered
Event
Confirmed
Horrible names
Venue
Booking
Purchase
Experts will Keep
using the specific
terms like “Meetup”
“Training” or
“Conference”
Redundancy Pain
Design
Planning
Sales
Inventory
Logistics
Tracking
Training
Summary
Public
Event
Ticket
Sale
Open
Event
Printables
Register
Attendee
Purchase
Ticket
Open
Sales
Schedule
Confirm
Cancel
Close
Sales
Cancel
Attendee
Session
Plan
Ticket
Plan
…
Public Training
Event
Coordination
Policy
Open
Registra
tions
(capacity)
Close
Registrations
Ticket
Purchased
Attendee
Registered
Event
Confirmed
Double Capacity?
Venue
Booking
YaGNI!!!
A single use case might
not be enough
We are in the core: some principles are not dogmas
"
"
Private Trainings
Design
Planning
Sales
Inventory
Logistics
Tracking
Training
Summary
Public
Event
Deal
Open
Event
Printables
Register
Attendee
Schedule
Confirm
Cancel
Cancel
Attendee
Session
Plan
…
Private
Training
Coordination
Policy
Open
Registra
tions
(capacity)
Close
Registrations
Attendee
Registered
Event
Confirmed
Private
Training
Coordination
Policy
Deal
signed
Materials
Printed
Very Limited
changes,
without opening
boxes.
Printables
Online Training
Design
Planning
Sales
Inventory
Logistics
Tracking
Training
Summary
Public
Event
Ticket
Sale
Open
Event
Printables
Register
Attendee
Purchase
Ticket
Open
Sales
Schedule
Confirm
Cancel
Close
Sales
Cancel
Attendee
Session
Plan
Ticket
Plan
…
Public Online
Training
Policy
Open
Registra
tions
(capacity)
Close
RegistrationsRegistration
Policy
Ticket
Purchased Attendee
Registered
Courseware
Policy
One more!
Delivery
Online
Session
Schedule
Start
Purchase
Very Limited
changes,
without opening
boxes.
Business-Driven Stressors
Can I have [This] without [That]?
Can I have [Reservations] without a [Ticket]?
Is this the Exception or the Rule?
It’s always a [Bundle], sometimes a simple one.
Can I have [This] and [That]?
Online Private
Design
Planning
Sales
Inventory
Logistics
Tracking
Training
Summary
Public
Event
Deal
Open
Event
Printables
Register
Attendee
Schedule
Confirm
Cancel
Cancel
Attendee
Session
Plan
Ticket
Plan
…
Private
Online
Training
Policy
Open
Registra
tions
(capacity)
Close
Registrations
Attendee
Registered
Courseware
Policy
One more!
Delivery
Online
Session
Schedule
Start
Deal
signed
Progressively
declining cost
of new options
More Options
Hybrid Trainings
Combo Tickets
Composite Events
Resellers and Partners Conferences and Workshops
Books as Courseware
Top-Down Forces
Interacting with Domain Experts
Detecting Business Lines
Imposing phases and archetypes
Bottom-Up Forces
Detecting Building Blocks - Types
Making Them Safe
Session Layout
•Originally ok with int duration
•Pandemic as a majestic stressor:
•Exact Timing became vital information for online sessions
•Empty spaces become interesting for different activity types
Session
Layout
Parallel Models
Design
Delivery
Session
Plan
Session
Type
Session
Session
Duration
Session
Schedule
Scheduled
Session
On May 17th
On may 17th, 9:30 am
3 Days
Day 1, 9:30 am
Session
Type
Zoom
Google
Calendar
For Reuse!!!
For Business
Composability!!!
How much of this journey
can involve domain
experts?
I suspect “It Depends” is a clear winner here.
"
"
Feeling guilty
Design
Delivery
Session
Plan
Session
Type
Session
Session
Duration
Session
Schedule
Scheduled
Session
Horrible names
On May 17th
On may 17th, 9:30 am
3 Days
Day 1, 9:30 am
Session
Type
Problem with this pattern?
Experts think they’re talking about the same thing:
You know they’re not
Draft Model Executable Tracking
Validation
Propose
Adjust
Annotate
Comment
Finalize
Schedule
Cancel
Session Session Type Session Session Type
Duration
Schedule
Duration
Comment
Measure
Start
Join
Terminate
Session Session Type
Duration
What is visible?
Session
Plan
Ticket
Plan
Training
Summary
Schedule
Public
Event
Ticket
Sale
Open
Event
Session
Type
Session
Session
Duration
Session
Can Domain
Experts help
here?
State as an Illusion
The final trick!
I’ll follow you
everywhere my
beloved domain
expert!!
Read Model
Confirm Retire
Amazing Workshop
With John Doe
June 25 - 2023
90 days till deadline
5 of 16 ticket sold
UNCONFIRMED
Threshold at 8
-John Smith - Early Bird Ticket
-Mario Rossi - Early Bird Ticket
-Francesca Bianchi - Early Bird Ticket
-Sylvie Bouchard - Standard Ticket
-Nick Fury - Special Ticket
The information needed to
make a decision
A few things are
missing, I am lazy
That’s what you want to see!
There’s more than one!
Planning:
Time:
Registration / Sales:
I can show you
Everything!
I just need to see:
UNCONFIRMED
CONFIRMED
RUNNING
PAST
CANCELED
User Perceived State Machine
UNCONFIRMED
CONFIRMED
RUNNING
PAST
CANCELED
User Perceived State Machine
Sales Event Time Read Model
Closed Unconfirmed Future Stealth
Closed Confirmed Future Confirmed
Closed Canceled Future Canceled
Open Unconfirmed Future Unconfirmed
Open Confirmed Future Confirmed
Open Canceled Future Error
Closed Unconfirmed Present Forgot something?
Closed Confirmed Present Running
Closed Canceled Present '''''''
Open … Present Hey Wait a Minute!
… … … …
Surprise states!
But…
I’ll couple
everything to give
you the state
machine you
want!
It’s an illusion!
Spice up your models!
Photo by Tamanna Rumee on Unsplash
Give yourself
more than one
option
Add Layers to your whirlpool!
Low-fi Matters
Digital Tools are changing
your brain priorities
I enter a session to model, and I find myself aligning rectangles and
making arrows clear.
Get Yourself a Green Bar!
Combining Different Styles
Little Cherry on top
A Scatter-Gather Style
Design
Planning
Sales
Inventory
Logistics
Tracking
Training
Summary
Public
Event
Open
Event
Printables
Venue
Booking
Ticket
Sale
Purchase
State-Based
Aggregates (or
nobody cares about
your intermediate
events anyway)
Structural
composition and
possible
collaboration
Specifications as
warnings.
Read Models on
Steroids, focus on
information
readability and
sense-making for
the users.
EventSourcing on
multiple parallel
axes: events are
meaningful for the
listeners
Policies -> Sagas or
Process Managers
to allow business
flexibility
Draft Executable Tracking
Possible upscale to
state-driven style
Title
Pick the right tool for the
job
Maybe we can avoid it!
Lightweight Boundaries
Postpone physical separation as long as you can.
Make sure your team has enough discipline to support the logical
separation.
Wrap up!
Biases and shortcuts are
nudging you to repeat past
errors
I’ll follow you
everywhere my
beloved domain
expert!!
Why don’t we just
patch the legacy?
Sometimes we gotta Pull!
Photo by Ugur Arpaci on Unsplash
Design Integrity is
YOUR BUSINESS
Can’t outsource it to the
Domain Expert
You Can Start Clean
Quick and Dirty is not the only option
Give yourself one more
alternatives
Your 1st choice is probably unsafe
What is visible?
Session
Plan
Ticket
Plan
Training
Summary
Schedule
Public
Event
Ticket
Sale
Open
Event
Session
Type
Session
Session
Duration
Session
Can Domain
Experts help
here?
What is visible?
Read Models
Aggregates
UI
Not everything
needs to be
discussed in the
same way
Commands
(Labels and
Intentions)
Commands
Events
Policies
Business Composability
Is
Business Confidence
But make sure it comes from code, not from PowerPoints