Domain-Driven Design
For Real
Cyrille Martraire
@cyriux
1968
Banker
&
Programmer
”In 1968 DDD
was a tautology”
David West, DDD Europe 2017
NATO Software Engineering
Conference 1968
DDD for real
DDD for real
business
analyst
software
developer
DDDBusiness
Expertise
Software
Expertise
DDD for real
Passionate
developer
PARIS
Since 1999
@cyriux
Cyrille Martraire
Paris Software
Craftsmanship Community
http://www.meetup.com/paris-software-craftsmanship/
TDD
BDD
DDD
Legacy
DDD?
DDD for real
DDD for real
h"p://www.virtual-genius.com/blog/post/Domain-Driven-Design-Immersion-Course-e28093-Part-5.aspx
DDD for real
Seniors	Developers
h"p://www.thisisio.ie/blog/arDcle/149/hiring_senior_developer
OFTENMISTAKEN
No Tool Needed
CQRS: most popular
WELL-respected
My DDD Map
21
Modeling == Code
Strategic Design
Bounded Context
Context Mapping
CQRS / EC
large-scale structures
Tactical Design
Value Object
Entities
Repository
Aggregate
(patterns)
Domain Events
Focus on Core Domain
Ubiquitous Language
(BDD)
Hexagonal Architecture
FP + OO style
Immutable
Side-Effect-Free
Patterns
Monoids
Bubble Context & Legacy
Emerging Design
DDD Map
22
Modeling == Code
Strategic Design
Bounded Context
Context Mapping
CQRS / EC
large-scale structures
Tactical Design
Value Object
Entities
Repository
Aggregate
(patterns)
Domain Events
Focus on Core Domain
Ubiquitous Language
(BDD)
Hexagonal Architecture
FP + OO style
Immutable
Side-Effect-Free
Patterns
Monoids
Bubble Context & Legacy
Emerging Design
DDD for real
DDD Essentials
Curious about the domain
Talking the Domain Language
Focus on Core Domain
Modeling == Code
Strategic Design
(+ techniques to achieve that)
24
Example
PLZ!
Domain Expert
Please add a
discount code to the
purchase!
You mean the
shopping cart?
Yes, this is what I
meant
(of course)
Ok, so let’s add a
voucher field to the
class ”BasketModel”
DDD for real
Purchase
Shopping Cart
BasketModel
32
problem
Systematic
Translation
(waste of time + confusion as-a-service)
solution
Ubiquitous
Language
talk the domain language
Ubiquitous Language
• Naming
•Searchable
•Easy to pronounce
•No abbreviation
• Definitions
•Shared definition
•Understand, not just
a vocabulary
DDD for real
Everyone
talking the
Domain Language
Everywhere
(even in the code)
37
Everyone
talking the
Domain Language
Everywhere
(even in the code)
38
Everyone
talking the
Domain Language
Everywhere
(even in the code)
39
90%
Business
Domain
Language
here
Extract a word cloud
from your code BAD
Extract a word cloud
from your code Better
null
DDD style of code?
• No technical pollu5on	
• Spring,	Hibernate,	logger	
• javax.*	
• SQL
[Object Calisthenics]
1. Wrap all primitives and strings
2. Use only one dot per line
3. Don’t abbreviate
4. Keep all classes small
5. Don’t use any classes with more
than two instance variables
6. Use first-class collections
7. Don’t use any getters/setters/
properties
45
Tactical Patterns
Value Objects
Entities
Domain Services
Domain Events
Repositories
DDD for real
Ubiquitous
Language
everywhere
47
So you mean
DDD is primarily just
talking business
domain?
48
DDD for real
Ubiquitous Language
everywhere
50
@cyriux
https://leanpub.com/livingdocumentation
BUY MY BOOK!
When to apply DDD?
52
WeWant:
WeWant:
Anapptodetect
paymentfrauds
Rich business domain
55
Risk is in the domain
Apply DDD!
56
WeWant:
Afeaturetobeatour
competition
Differentiating business
domain
58
Value is in the domain
Apply DDD!
59
WeWant:
AnotherTODOlistapp
Go CRUD!
61
Focus on the
Core Domain
62
Differentiating to
the business?
Apply DDD!
64
Not differentiating?
BUY
Domain
Curiosity
67
DDD for real
I only care about
Kubernetes
Hey!
Finance
is cool!
DDD for real
Oh, this
domain is
really cool!
Oh, this
domain is
really cool!
I’d like to
know it
better!
Start with
Examples
74
Scenarios
Intent
Scenarios
Concrete examples
BDD: probably your best
friend to start DDD
@cyriux
Modeling == Code
79
Example
PLZ!
Please add a new
discount mode
Where do I add that?
I know: I’ll add
the code in the
MainController
class!
MainController
28 fields here
…
245 methods here
…
6422 lines
DDD for real
problem
Code Gravity
big stuff attracts even more stuff and gets bigger
@carlopescio
solution
Domain
Modeling
business domain as code, literally
Payment
…
Discounting
…
Add the
feature
only here
Refactor based on your
domain understanding
89
Domain-Driven
Refactoring
90
Domain modeling in
practice
91
*NOT* UML/MDA!
h"p://depinfo.u-cergy.fr/projets/close2u/fr/tag/uml/
DDD for real
Kitten kitty = new Kitten(Attitude.ROCK_STAR);
Microphone mike = new Microphone();
kitty.sing(mike);
system.out.println(mike.playBack());
//”mew mew meeew”
DDD for real
Good modeling?
96
Learn the business domain
by reading the code
97
Learn the business domain
by reading the code
98
and running the code
We want IT
alignment blabla…
We want IT
alignment blabla…
I know how to do
that!
Once you know DDD…
DDD for real
Functional Area
|
Code Module
103
1-to-1
Example
PLZ!
105
decision making
vehicle dispatching
cyclic dependency!
106
decision making
vehicle dispatching
cyclic dependency!
107
decision making
vehicle dispatching
Which one to cut?
A business domain
Decision
108
109
decision making
vehicle dispatching
1 business decision
110
decision making
vehicle dispatching
technical impact
DDD for real
DDD for real
Strategic Design
113
Bounded Contexts
Explicitly define the context within which a model
applies. Explicitly set boundaries in terms of team
organization, usage within specific parts of the
application, and physical manifestations such as code
bases and database schemas. Keep the model strictly
consistent within these bounds, but don’t be distracted
or confused by issues outside.
Bounded Contexts
Explicitly define the context within which a model
applies. Explicitly set boundaries in terms of team
organization, usage within specific parts of the
application, and physical manifestations such as code
bases and database schemas. Keep the model strictly
consistent within these bounds, but don’t be distracted
or confused by issues outside.
Example
PLZ!
Customer
addressLine
zipcode
city
…
Hey!
Companies have a
different billing
address!
I know: let’s add it
with a flag!
Purchase
addressLine
zipcode
city
has2AddressesFlag
addressLine2
zipcode2
city2
Customer
addressLine
zipcode
city
has2AddressesFlag
addressLine2
zipcode2
city2
If (! has2AddressesFlag)
billing address line = …
billing zip code =
billing city =
else
billing address line = …
billing zip code =
billing city =
Customer
addressLine
zipcode
city
has2AddressesFlag
addressLine2
zipcode2
city2
If (! has2AddressesFlag)
billing address line = …
billing zip code =
billing city =
else
billing address line = …
billing zip code =
billing city =
Everywhere
DDD for real
problem
Code Mess
by lack of domain understanding
solution
Bounded
Contexts
split 1 big model by sub-domains
Split by business domains
125
Customer
addressLine
zipcode
city
date
amount
user
Account
addressLine
zipcode
city
Recipient
+
+
Shipping
BillingShopping Cart
Shipping
BillingShopping Cart
Shipping
BillingShopping Cart
Bounded Contexts
by domain
Customer
addressLine
zipcode
city
date
amount
user
Account
addressLine
zipcode
city
Recipient
+
+
New names
customer
≠
account
≠
recipient
130
Near Synonyms
Customer
addressLine
zipcode
city
date
amount
user
Account
addressLine
zipcode
city
Recipient
+
+
Suggest Contexts
Customer
addressLine
zipcode
city
date
amount
user
Account
addressLine
zipcode
city
Recipient
+
+
Default value:
billing address =
shipping address
But… that’s
massive duplication!
”No Duplication”
means ”Coupling”
Evolve differently in the
long term
135
addressLine
zipcode
city
Account
Billing
addressLine
zipcode
city
Recipient
Shipping
addressLine
zipcode
city
contactName
taxRegion
Account
Billing
addressLine
zipcode
city
Recipient
Shipping
addressLine
zipcode
city
contactName
taxRegion
Account
Billing
addressLine
zipcode
city
doorCode
availabilityTimeSlots
Recipient
Shipping
Purchase BillingUnit
DeliveryRequest
*
*
e.g. marketplace
DRY == Coupling
Bounded Contexts: We
decide to reduce coupling
at the cost of some
redundancy
140
What a book at Amazon?
•Catalog: Picture, title, authors, rating, format
(ebook or paper), category
•Recommandation: List of books often bought
together with it
•Shipping: Dimensions, weight, international
restrictions due to content
•Shopping cart: Price, discount eligible
•Customer review: List of (rating, review,
review rating)
•Book Search: title, isbn, authors
•Search Inside!: full-text content, copyright-
dealing policy
Different perspectives
My book is not your book
colleague
committer
collaborator
candidate
friend
peer
Polyglot persistence (random examples)
•Catalog: NoSQL
•Recommandation: Batch + GraphDB
•Shipping: RDBMS
•Shopping cart: RDBMS
•Customer review: Cassandra
•Book Search: Elastic Search
•Search Inside!: Redis + CDN
Team organization
•Catalog: Team 1
•Recommandation: Team 2
•Shipping: Team 3
•Shopping cart: Team 4
•Customer review: Team 5
•Book Search: Team 6
•Search Inside!: Team 7
DDD for real
DDD for real
by the way...
loosely-coupled,
service-oriented
architecture with
bounded context.
loosely-coupled,
service-oriented
architecture with
bounded context.
Adrian Cockcroft
Microservices!
DDD for real
DDD?
Identification au code
Identification au métier
DDD Framework?
DDD Framework?
What language?
What language?
Does not matter
(but easier with F#)
Is DDD for you?
• Do you feel close to XP?
• Do you love distributed caches?
How to go further?
Read the blue book
Read Martin Fowler
Try Event Storming
DDD for real
h"p://cathy313.centerblog.net/539-bisounours
@cyriux

More Related Content

PDF
Loosely Coupled DDD
PDF
Hexagonal at Scale, with DDD and microservices! - Voxxed Days microservices 2...
PDF
Bounded Context - DDD Europe Foundation Track
PDF
Sunny Tech 2019 - Craft Forever
PDF
Domain Modeling towards First Principles
PDF
Refactor your Specs - 2017 Edition
PDF
DDD beyond the infamous repository pattern - GeeCon Prague 2018
PDF
Apex Nirvana
Loosely Coupled DDD
Hexagonal at Scale, with DDD and microservices! - Voxxed Days microservices 2...
Bounded Context - DDD Europe Foundation Track
Sunny Tech 2019 - Craft Forever
Domain Modeling towards First Principles
Refactor your Specs - 2017 Edition
DDD beyond the infamous repository pattern - GeeCon Prague 2018
Apex Nirvana

Similar to DDD for real (20)

PDF
Serverless ddd
PPTX
Sean Farmar - Successfully Decomposing Your Monolith or UpdateUser Means Noth...
PDF
Generative Design 101 for Architecture, Engineering & Construction by Jad Del...
PDF
CAD Certification
PPTX
Behavior-driven Development and Lambdaj
PPTX
An Introduction to Domain Driven Design in PHP
PDF
SAP PowerDesigner Masterclass for the UK SAP Database & Technology User Group...
PDF
GoDaddy Customer Success Dashboard Using Apache Spark with Baburao Kamble
PPT
Model Driven Architectures
ODP
Mandeep2 Chopra
PDF
UX STRAT Online 2021 Presentation by Mike Kuniavsky, Accenture
PPT
Fashion Technologies
PDF
Reinventing the Transaction Script (NDC London 2020)
PDF
Ruby loves DDD
PDF
Moore Advanced Calculations in Calc Manager OW 20151015
PPTX
CodeBook at the Conferences
PDF
Domain Driven Design
PPTX
From concept to code
PDF
Datenstrategie der Zukunft - Technologietrends, die Sie kennen müssen
Serverless ddd
Sean Farmar - Successfully Decomposing Your Monolith or UpdateUser Means Noth...
Generative Design 101 for Architecture, Engineering & Construction by Jad Del...
CAD Certification
Behavior-driven Development and Lambdaj
An Introduction to Domain Driven Design in PHP
SAP PowerDesigner Masterclass for the UK SAP Database & Technology User Group...
GoDaddy Customer Success Dashboard Using Apache Spark with Baburao Kamble
Model Driven Architectures
Mandeep2 Chopra
UX STRAT Online 2021 Presentation by Mike Kuniavsky, Accenture
Fashion Technologies
Reinventing the Transaction Script (NDC London 2020)
Ruby loves DDD
Moore Advanced Calculations in Calc Manager OW 20151015
CodeBook at the Conferences
Domain Driven Design
From concept to code
Datenstrategie der Zukunft - Technologietrends, die Sie kennen müssen
Ad

More from Cyrille Martraire (13)

PDF
Domain modeling for Digital Transformations (FlowCon Paris 2019 edition)
PDF
Les effets inattendus du passage en Features Teams à grande échelle -ScrumDay...
PDF
Interviewing Domain Experts - Heuristics From the Trenches (DDD Europe 2016 M...
PDF
DDD patterns that were not in the book
PDF
Living Documentation (NCrafts Paris 2015, DDDx London 2015, BDX.io 2015, Code...
PDF
Legacy Code: Evolve or Rewrite?
PDF
Ur Domain Haz Monoids DDDx NYC 2014
PDF
Ur Domain Haz Monoids
PDF
Refactor your specs! Øredev 2013
PDF
DDD session BrownBagLunch (FR)
PDF
I T.A.K.E. talk: "When DDD meets FP, good things happen"
PDF
Domain-Driven Design in legacy application
PDF
Tour d'horizon de Domain-Driven Design Avril 2012 autour d'un retour d'expéri...
Domain modeling for Digital Transformations (FlowCon Paris 2019 edition)
Les effets inattendus du passage en Features Teams à grande échelle -ScrumDay...
Interviewing Domain Experts - Heuristics From the Trenches (DDD Europe 2016 M...
DDD patterns that were not in the book
Living Documentation (NCrafts Paris 2015, DDDx London 2015, BDX.io 2015, Code...
Legacy Code: Evolve or Rewrite?
Ur Domain Haz Monoids DDDx NYC 2014
Ur Domain Haz Monoids
Refactor your specs! Øredev 2013
DDD session BrownBagLunch (FR)
I T.A.K.E. talk: "When DDD meets FP, good things happen"
Domain-Driven Design in legacy application
Tour d'horizon de Domain-Driven Design Avril 2012 autour d'un retour d'expéri...
Ad

Recently uploaded (20)

PDF
Five Habits of High-Impact Board Members
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
Unlock new opportunities with location data.pdf
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
Getting Started with Data Integration: FME Form 101
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
A comparative study of natural language inference in Swahili using monolingua...
PPTX
The various Industrial Revolutions .pptx
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Zenith AI: Advanced Artificial Intelligence
PPT
What is a Computer? Input Devices /output devices
PDF
Hybrid model detection and classification of lung cancer
PPTX
observCloud-Native Containerability and monitoring.pptx
PPTX
Web Crawler for Trend Tracking Gen Z Insights.pptx
PPTX
Tartificialntelligence_presentation.pptx
PPTX
Modernising the Digital Integration Hub
Five Habits of High-Impact Board Members
sustainability-14-14877-v2.pddhzftheheeeee
Unlock new opportunities with location data.pdf
Final SEM Unit 1 for mit wpu at pune .pptx
Getting Started with Data Integration: FME Form 101
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Univ-Connecticut-ChatGPT-Presentaion.pdf
A novel scalable deep ensemble learning framework for big data classification...
A comparative study of natural language inference in Swahili using monolingua...
The various Industrial Revolutions .pptx
NewMind AI Weekly Chronicles – August ’25 Week III
Group 1 Presentation -Planning and Decision Making .pptx
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Zenith AI: Advanced Artificial Intelligence
What is a Computer? Input Devices /output devices
Hybrid model detection and classification of lung cancer
observCloud-Native Containerability and monitoring.pptx
Web Crawler for Trend Tracking Gen Z Insights.pptx
Tartificialntelligence_presentation.pptx
Modernising the Digital Integration Hub

DDD for real