SlideShare a Scribd company logo
1 of 33
How does
Domain-Driven
Design work?
Tomaš Maconko
tomasmaconko@gmail.com
What is it?
“That’s just a rubbish theory!”
“Its just another way to structure your code!”
“Its hard to understand!”
“It requires lots of useless coding!”
“Nobody wants to use it!”
What is it?
“Domain-driven design (DDD)
is an approach to software
development for complex
needs by connecting
the implementation to an
evolving model.”
What is complexity?
•Business is the domain
•Complexity is the domain (problem) itself
•Domain consists of complex processes,
workflows, rules etc.
•Different specialists collaborate together to
make business value
Domain areas
Core subdomain
Supporting subdomains
Core subdomain and supporting subdomains
• DDD requires you to examine the business deeply
• It enables you to split up the problem into smaller
pieces (subdomains) to outline the core piece (core
subdomain)
• Allows you to pay attention to each piece separately
(even to work in different teams) and concentrate
mostly on the core
Core subdomain
Lets look inside
• Marketing
• Sales
• Billing
• Production
• Logistics
• Operations
• …
Bounded context
•A pattern in Domain-
Driven Design
•A chunk of solution
space
•Helps dealing with
large models
•Ubiquitous language
Ubiquitous language
Ubiquitous language
•Requires people in same bounded context using
same terms (dictionary)
•Same term is unambiguous for all team
members (domain experts, developers, QA,
etc.)
•Defined and maintainable by whole team
Car (production): engine,
wheels, body, …
Car (billing): car parts
expenses, salaries
Car (marketing): photo, video, description, …
Value object
•Does not have
identity
•Comparable by all its
attributes
•IMMUTABLE!
•Allows to encapsulate
business rules
Value
object
Entity
•A set of attributes and
verbs
•Has identity (engine ID
number)
•Cannot (logically) work
without aggregate
•Mutable
Entity
Aggregate and aggregate root
•Entity
•Joins related entities and value objects
•Encapsulates complex and state-dependent
requirements in domain classes
•It is highly recommended (required) to have
single aggregate per transaction
Aggregate
Aggregate root
Respository
• Encapsulates aggregates persistence and retrieval
• Persistence ignorance
• Can be used as abstraction for different underlying technologies
(SQL, NoSQL, web-services, caching, etc.)
• One repository per aggregate
Repository
How to combine stuff together?
2. Stop
pedal
pressed!
1. I listen for
stop pedal
pressed
1. I listen for
stop pedal
pressed
3. I handle it
3. I handle it
4. Started
stopping
4. Stop
lights
turned on
1. I listen for
acceleration
pedal pressed
Domain event
•Messages in past tense
•Result of completed command
•Integrates aggregates or bounded contexts with
minimal coupling and dependencies
•Reduces the number of changes in existing code
•Improves responsiveness (asynchronous
processing)
Pros
• Involves team into domain analysis
• Helps splitting and understanding
the domain
• Unambiguous terms
• Changes the way developers think
about solution
• Strong domain model
• Clean and maintainable code
DDD
Domain
Cons
•Requires team time and effort for analysis
•Requires stronger skills on modeler side and
OOP
•Complicates small systems
•Requires time to define UL
DDD
So, what next?
• CQRS
• Event sourcing
• Microservices
How DDD Works: An Introduction to Domain-Driven Design

More Related Content

Similar to How DDD Works: An Introduction to Domain-Driven Design

Customizing ERModernLook Applications
Customizing ERModernLook ApplicationsCustomizing ERModernLook Applications
Customizing ERModernLook ApplicationsWO Community
 
Web components, so close!
Web components, so close!Web components, so close!
Web components, so close!Aleks Zinevych
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Marco Breveglieri
 
How to organize the business layer in software
How to organize the business layer in softwareHow to organize the business layer in software
How to organize the business layer in softwareArnaud LEMAIRE
 
The DITA Iceberg, DITA Europe 2016
The DITA Iceberg, DITA Europe 2016The DITA Iceberg, DITA Europe 2016
The DITA Iceberg, DITA Europe 2016IXIASOFT
 
Domain Driven Design - Building Blocks
Domain Driven Design - Building BlocksDomain Driven Design - Building Blocks
Domain Driven Design - Building BlocksMark Windholtz
 
Deep Dive into the Idea of Software Architecture
Deep Dive into the Idea of Software ArchitectureDeep Dive into the Idea of Software Architecture
Deep Dive into the Idea of Software ArchitectureMatthew Clarke
 
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven DesignNETFest
 
Domain Driven Design - Distillation - Chapter 15
Domain Driven Design - Distillation - Chapter 15Domain Driven Design - Distillation - Chapter 15
Domain Driven Design - Distillation - Chapter 15Mark Windholtz
 
Domain-Driven Design (Artur Trosin Product Stream)
Domain-Driven Design (Artur Trosin Product Stream)Domain-Driven Design (Artur Trosin Product Stream)
Domain-Driven Design (Artur Trosin Product Stream)IT Arena
 
5 Common Mistakes You are Making on your Website
 5 Common Mistakes You are Making on your Website 5 Common Mistakes You are Making on your Website
5 Common Mistakes You are Making on your WebsiteAcquia
 
Wessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdf
Wessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdfWessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdf
Wessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdfWessel Loth
 
An Introduction to Domain Driven Design in PHP
An Introduction to Domain Driven Design in PHPAn Introduction to Domain Driven Design in PHP
An Introduction to Domain Driven Design in PHPChris Renner
 

Similar to How DDD Works: An Introduction to Domain-Driven Design (20)

Customizing ERModernLook Applications
Customizing ERModernLook ApplicationsCustomizing ERModernLook Applications
Customizing ERModernLook Applications
 
Web components, so close!
Web components, so close!Web components, so close!
Web components, so close!
 
Introduction to DDD
Introduction to DDDIntroduction to DDD
Introduction to DDD
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016
 
How to organize the business layer in software
How to organize the business layer in softwareHow to organize the business layer in software
How to organize the business layer in software
 
The DITA Iceberg, DITA Europe 2016
The DITA Iceberg, DITA Europe 2016The DITA Iceberg, DITA Europe 2016
The DITA Iceberg, DITA Europe 2016
 
Stackato v3
Stackato v3Stackato v3
Stackato v3
 
Domain Driven Design - Building Blocks
Domain Driven Design - Building BlocksDomain Driven Design - Building Blocks
Domain Driven Design - Building Blocks
 
Deep Dive into the Idea of Software Architecture
Deep Dive into the Idea of Software ArchitectureDeep Dive into the Idea of Software Architecture
Deep Dive into the Idea of Software Architecture
 
SDWest2005Goetsch
SDWest2005GoetschSDWest2005Goetsch
SDWest2005Goetsch
 
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
 
Stackato
StackatoStackato
Stackato
 
Domain Driven Design - Distillation - Chapter 15
Domain Driven Design - Distillation - Chapter 15Domain Driven Design - Distillation - Chapter 15
Domain Driven Design - Distillation - Chapter 15
 
Domain-Driven Design (Artur Trosin Product Stream)
Domain-Driven Design (Artur Trosin Product Stream)Domain-Driven Design (Artur Trosin Product Stream)
Domain-Driven Design (Artur Trosin Product Stream)
 
5 Common Mistakes You are Making on your Website
 5 Common Mistakes You are Making on your Website 5 Common Mistakes You are Making on your Website
5 Common Mistakes You are Making on your Website
 
Wessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdf
Wessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdfWessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdf
Wessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdf
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
An Introduction to Domain Driven Design in PHP
An Introduction to Domain Driven Design in PHPAn Introduction to Domain Driven Design in PHP
An Introduction to Domain Driven Design in PHP
 
Stackato v5
Stackato v5Stackato v5
Stackato v5
 
Stackato v6
Stackato v6Stackato v6
Stackato v6
 

How DDD Works: An Introduction to Domain-Driven Design

  • 1. How does Domain-Driven Design work? Tomaš Maconko tomasmaconko@gmail.com
  • 2. What is it? “That’s just a rubbish theory!” “Its just another way to structure your code!” “Its hard to understand!” “It requires lots of useless coding!” “Nobody wants to use it!”
  • 3.
  • 4. What is it? “Domain-driven design (DDD) is an approach to software development for complex needs by connecting the implementation to an evolving model.”
  • 5. What is complexity? •Business is the domain •Complexity is the domain (problem) itself •Domain consists of complex processes, workflows, rules etc. •Different specialists collaborate together to make business value
  • 6.
  • 8. Core subdomain and supporting subdomains • DDD requires you to examine the business deeply • It enables you to split up the problem into smaller pieces (subdomains) to outline the core piece (core subdomain) • Allows you to pay attention to each piece separately (even to work in different teams) and concentrate mostly on the core
  • 10. Lets look inside • Marketing • Sales • Billing • Production • Logistics • Operations • …
  • 11.
  • 12. Bounded context •A pattern in Domain- Driven Design •A chunk of solution space •Helps dealing with large models •Ubiquitous language
  • 14. Ubiquitous language •Requires people in same bounded context using same terms (dictionary) •Same term is unambiguous for all team members (domain experts, developers, QA, etc.) •Defined and maintainable by whole team
  • 15. Car (production): engine, wheels, body, … Car (billing): car parts expenses, salaries Car (marketing): photo, video, description, …
  • 16.
  • 17. Value object •Does not have identity •Comparable by all its attributes •IMMUTABLE! •Allows to encapsulate business rules
  • 19. Entity •A set of attributes and verbs •Has identity (engine ID number) •Cannot (logically) work without aggregate •Mutable
  • 21. Aggregate and aggregate root •Entity •Joins related entities and value objects •Encapsulates complex and state-dependent requirements in domain classes •It is highly recommended (required) to have single aggregate per transaction
  • 24. Respository • Encapsulates aggregates persistence and retrieval • Persistence ignorance • Can be used as abstraction for different underlying technologies (SQL, NoSQL, web-services, caching, etc.) • One repository per aggregate
  • 26.
  • 27. How to combine stuff together? 2. Stop pedal pressed! 1. I listen for stop pedal pressed 1. I listen for stop pedal pressed 3. I handle it 3. I handle it 4. Started stopping 4. Stop lights turned on 1. I listen for acceleration pedal pressed
  • 28. Domain event •Messages in past tense •Result of completed command •Integrates aggregates or bounded contexts with minimal coupling and dependencies •Reduces the number of changes in existing code •Improves responsiveness (asynchronous processing)
  • 29.
  • 30. Pros • Involves team into domain analysis • Helps splitting and understanding the domain • Unambiguous terms • Changes the way developers think about solution • Strong domain model • Clean and maintainable code DDD Domain
  • 31. Cons •Requires team time and effort for analysis •Requires stronger skills on modeler side and OOP •Complicates small systems •Requires time to define UL DDD
  • 32. So, what next? • CQRS • Event sourcing • Microservices