SlideShare a Scribd company logo
Software Architecture Meetup
November 2018
Domain Driven Design (DDD)
Muhammad Ali
Software Architect VentureDive
Conway's law
“Any organization that designs a system (defined more broadly here than just
information systems) will inevitably produce a design whose structure is a copy of the
organization's communication structure.”
What is domain-driven design
● Domain-Driven Design is an approach to the development of complex software in
which we:
○ Focus on core domain
○ Explore models in a creative collaboration of domain practitioners and software practitioners
○ Speak a ubiquitous language with in an explicitly bounded context
Goal
● A domain specific project that needs to leverage multiple realms of expertise
specifically
○ Design and Developer expertise
○ Domain specific expertise
Complication
● Most of the times developers speak in terms of Objects, composition, aggregation,
inheritance, polymorphism, pure functions etc.
● They talk more about technical solution rather than the problem itself.
● At times they don’t understand the underlying complexity and overcommit.
● Domain expert don’t know any of these, he has his own jargons regarding the
domain.
● For example marketing people talking about leads, ads, campaigns, budgeting
units etc.
● Similarly domain expert in airline talking about crew planning, SAFE, roster
planning, FBO, PFA etc.
Solution
● Strengthen the communication process and establish a methodology for making
those communication more robust
● This is primarily accomplished by developing a UBIQUITOUS LANGUAGE and
single model
● Make sure your developers speak this ubiquitous language.
● Persistent use of the UBIQUITOUS LANGUAGE will force the model's
weaknesses into the open
● Building a language like this has a clear outcome:
○ Language and model are strongly interconnected with each other
○ Any changes to the language will be recognized as changes in the domain model
Domain Model
● A system of abstraction that describes selected aspects of a domain and can be
used to solve problems related to that domain.
● A domain model in not a particular(UML) diagram(unlike Model-Driven
Design), it is the idea that diagram is intended to convey.
● Model can be an expression in natural language, code or a diagram.
● Model is not a design artifact
● Model are the backbone of domain-driven design
● The model is distilled knowledge
● It is not just the knowledge in a domain expert's head; it is a rigorously organized
and selective abstraction of that knowledge
Implementation
● Once Domain Model is defined, you can identify different components based on
their properties
● You can divide your solution into different layers(so called layered architecture,
MVP, MVC etc)
● For example following we can break down our solution into following layers
○ Presentation Layer (UI or Rest/SOAP)
○ Application Layer (Define the jobs that software is supposed to do and direct the expressive
domain objects to work out problems.)
○ Domain Layer(Contains Business Logic)
○ Infrastructure Layer(Provides generic technical capabilities, like message sending, persistence etc.)
● There can be multiple layers with different names however Domain-Driven
design only requires domain layer.
Entities
● An object defined primarily by its identity is called an Entity.
● Each entity must have an operational way of establishing its identity with another
object
● An identifying attribute must be guaranteed to be unique within the system
however that system is defined, even if distributed, even when objects are
archived
Value Objects
● An object that represents a descriptive aspect of the domain with no conceptual
identity is called a Value Object.
● The attributes that make up a Value Object should form a conceptual whole
● Immutability should also be considered when designing Value Objects
● As long as a Value Object is immutable, change management is simple
Services
● There are important domain operations that can't find a natural home in an Entity
or Value Object
● A Service is an operation offered as an interface that stands alone in the model,
without encapsulating state, as Entities and Value Objects do.
● Services are a common pattern in technical frameworks, but they can also apply in
the domain layer.
● A good service has following characteristics
○ The interface is defined in terms of other elements of the domain model
○ The operation relates to a domain concept that is not a natural part of an Entity or Value Object.
Aggregates
● An aggregate is a cluster of domain objects that can be treated as a single unit
● Aggregates are the basic element of transfer of data storage - you request to load
or save whole aggregates. Transactions should not cross aggregate boundaries.
● An aggregate will have one of its component objects be the aggregate root.
● Any references from outside the aggregate should only go to the aggregate root.
● The root can thus ensure the integrity of the aggregate as a whole.
● A delete operation must remove everything within the aggregate boundary at
once
● When a change to any object within the aggregate boundary is committed, all
invariants of the whole aggregate must be satisfied. When a change to any object
within the aggregate boundary is committed, all invariants of the whole aggregate
must be satisfied.
Bounded Context
● Bounded Context is a central pattern in Domain-Driven Design
● DDD deals with large models by dividing them into different Bounded Contexts
and being explicit about their interrelationships
● Total unification of the domain model for a large system will not be feasible or
cost-effective
● So instead DDD divides up a large system into Bounded Contexts, each of which
can have a unified model
Context Map
● An individual Bounded Context still does not provide a global view. The context
of other models may still be vague and in flux
● Code reuse between Bounded Context is a hazard to be avoided.
● A Context Map is the overlap between project management and software design.
● A Context Map is a document which outlines the different Bounded Contexts and
the relationships between them.
● The level of detail may vary. What it is important is that everyone working on the
project shares and understands it.
Questions?
Ad

More Related Content

Similar to Introduction to Domain driven design (20)

Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
Up2 Technology
 
Essential Software Architecture - Chapter 1 Understanding Software Architectu...
Essential Software Architecture - Chapter 1 Understanding Software Architectu...Essential Software Architecture - Chapter 1 Understanding Software Architectu...
Essential Software Architecture - Chapter 1 Understanding Software Architectu...
John Ortiz
 
Unit iv -Documenting and Implementation of Software Architecture
Unit iv -Documenting and Implementation of Software ArchitectureUnit iv -Documenting and Implementation of Software Architecture
Unit iv -Documenting and Implementation of Software Architecture
Dhivyaa C.R
 
DOMAIN DRIVER DESIGN
DOMAIN DRIVER DESIGNDOMAIN DRIVER DESIGN
DOMAIN DRIVER DESIGN
Mohammed Fazuluddin
 
Unit IV Software Engineering
Unit IV Software EngineeringUnit IV Software Engineering
Unit IV Software Engineering
Nandhini S
 
Domain Driven Design Quickly
Domain Driven Design QuicklyDomain Driven Design Quickly
Domain Driven Design Quickly
Mariam Hakobyan
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
wojtek_s
 
Domain Drive Design: A Very Short Introduction for Business People
Domain Drive Design: A Very Short Introduction for Business PeopleDomain Drive Design: A Very Short Introduction for Business People
Domain Drive Design: A Very Short Introduction for Business People
Emre Sevinç
 
Domain driven design: a gentle introduction
Domain driven design:  a gentle introductionDomain driven design:  a gentle introduction
Domain driven design: a gentle introduction
Asher Sterkin
 
Clean architecture
Clean architectureClean architecture
Clean architecture
.NET Crowd
 
DDD eXchange
DDD eXchangeDDD eXchange
DDD eXchange
Skills Matter
 
Design Patterns Part1
Design Patterns  Part1Design Patterns  Part1
Design Patterns Part1
Tom Chen
 
From class to architecture
From class to architectureFrom class to architecture
From class to architecture
Marcin Hawraniak
 
UNIT_III_Design Engineering, design engineering, architecture, patterns, UML ...
UNIT_III_Design Engineering, design engineering, architecture, patterns, UML ...UNIT_III_Design Engineering, design engineering, architecture, patterns, UML ...
UNIT_III_Design Engineering, design engineering, architecture, patterns, UML ...
MANOJ964697
 
Architecture and UML diagrams, types of UML diagrams, types of architecture a...
Architecture and UML diagrams, types of UML diagrams, types of architecture a...Architecture and UML diagrams, types of UML diagrams, types of architecture a...
Architecture and UML diagrams, types of UML diagrams, types of architecture a...
MANOJ964697
 
Domain Driven Design - Distillation - Chapter 15
Domain Driven Design - Distillation - Chapter 15Domain Driven Design - Distillation - Chapter 15
Domain Driven Design - Distillation - Chapter 15
Mark Windholtz
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
Nader Albert
 
Design Patterns In Scala
Design Patterns In ScalaDesign Patterns In Scala
Design Patterns In Scala
Knoldus Inc.
 
Intro to Domain Driven Design
Intro to Domain Driven DesignIntro to Domain Driven Design
Intro to Domain Driven Design
Yaniv Preiss
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
Harsh Jegadeesan
 
Essential Software Architecture - Chapter 1 Understanding Software Architectu...
Essential Software Architecture - Chapter 1 Understanding Software Architectu...Essential Software Architecture - Chapter 1 Understanding Software Architectu...
Essential Software Architecture - Chapter 1 Understanding Software Architectu...
John Ortiz
 
Unit iv -Documenting and Implementation of Software Architecture
Unit iv -Documenting and Implementation of Software ArchitectureUnit iv -Documenting and Implementation of Software Architecture
Unit iv -Documenting and Implementation of Software Architecture
Dhivyaa C.R
 
Unit IV Software Engineering
Unit IV Software EngineeringUnit IV Software Engineering
Unit IV Software Engineering
Nandhini S
 
Domain Driven Design Quickly
Domain Driven Design QuicklyDomain Driven Design Quickly
Domain Driven Design Quickly
Mariam Hakobyan
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
wojtek_s
 
Domain Drive Design: A Very Short Introduction for Business People
Domain Drive Design: A Very Short Introduction for Business PeopleDomain Drive Design: A Very Short Introduction for Business People
Domain Drive Design: A Very Short Introduction for Business People
Emre Sevinç
 
Domain driven design: a gentle introduction
Domain driven design:  a gentle introductionDomain driven design:  a gentle introduction
Domain driven design: a gentle introduction
Asher Sterkin
 
Clean architecture
Clean architectureClean architecture
Clean architecture
.NET Crowd
 
Design Patterns Part1
Design Patterns  Part1Design Patterns  Part1
Design Patterns Part1
Tom Chen
 
From class to architecture
From class to architectureFrom class to architecture
From class to architecture
Marcin Hawraniak
 
UNIT_III_Design Engineering, design engineering, architecture, patterns, UML ...
UNIT_III_Design Engineering, design engineering, architecture, patterns, UML ...UNIT_III_Design Engineering, design engineering, architecture, patterns, UML ...
UNIT_III_Design Engineering, design engineering, architecture, patterns, UML ...
MANOJ964697
 
Architecture and UML diagrams, types of UML diagrams, types of architecture a...
Architecture and UML diagrams, types of UML diagrams, types of architecture a...Architecture and UML diagrams, types of UML diagrams, types of architecture a...
Architecture and UML diagrams, types of UML diagrams, types of architecture a...
MANOJ964697
 
Domain Driven Design - Distillation - Chapter 15
Domain Driven Design - Distillation - Chapter 15Domain Driven Design - Distillation - Chapter 15
Domain Driven Design - Distillation - Chapter 15
Mark Windholtz
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
Nader Albert
 
Design Patterns In Scala
Design Patterns In ScalaDesign Patterns In Scala
Design Patterns In Scala
Knoldus Inc.
 
Intro to Domain Driven Design
Intro to Domain Driven DesignIntro to Domain Driven Design
Intro to Domain Driven Design
Yaniv Preiss
 

More from Muhammad Ali (8)

Communication Mechanisms, Past, Present & Future
Communication Mechanisms, Past, Present & FutureCommunication Mechanisms, Past, Present & Future
Communication Mechanisms, Past, Present & Future
Muhammad Ali
 
WebRTC Introduction & Basics
WebRTC Introduction & BasicsWebRTC Introduction & Basics
WebRTC Introduction & Basics
Muhammad Ali
 
Introduction to Architectural Katas
Introduction to Architectural KatasIntroduction to Architectural Katas
Introduction to Architectural Katas
Muhammad Ali
 
DBMS Modeling & Optimization
DBMS Modeling & OptimizationDBMS Modeling & Optimization
DBMS Modeling & Optimization
Muhammad Ali
 
Android architectural components
Android architectural componentsAndroid architectural components
Android architectural components
Muhammad Ali
 
Architectural katas
Architectural katasArchitectural katas
Architectural katas
Muhammad Ali
 
Software Architecture Meetup introduction
Software Architecture Meetup introductionSoftware Architecture Meetup introduction
Software Architecture Meetup introduction
Muhammad Ali
 
Practicing DDD & CQRS
Practicing DDD & CQRSPracticing DDD & CQRS
Practicing DDD & CQRS
Muhammad Ali
 
Communication Mechanisms, Past, Present & Future
Communication Mechanisms, Past, Present & FutureCommunication Mechanisms, Past, Present & Future
Communication Mechanisms, Past, Present & Future
Muhammad Ali
 
WebRTC Introduction & Basics
WebRTC Introduction & BasicsWebRTC Introduction & Basics
WebRTC Introduction & Basics
Muhammad Ali
 
Introduction to Architectural Katas
Introduction to Architectural KatasIntroduction to Architectural Katas
Introduction to Architectural Katas
Muhammad Ali
 
DBMS Modeling & Optimization
DBMS Modeling & OptimizationDBMS Modeling & Optimization
DBMS Modeling & Optimization
Muhammad Ali
 
Android architectural components
Android architectural componentsAndroid architectural components
Android architectural components
Muhammad Ali
 
Architectural katas
Architectural katasArchitectural katas
Architectural katas
Muhammad Ali
 
Software Architecture Meetup introduction
Software Architecture Meetup introductionSoftware Architecture Meetup introduction
Software Architecture Meetup introduction
Muhammad Ali
 
Practicing DDD & CQRS
Practicing DDD & CQRSPracticing DDD & CQRS
Practicing DDD & CQRS
Muhammad Ali
 
Ad

Recently uploaded (20)

[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts
Dimitrios Platis
 
Download 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-ActivatedDownload 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-Activated
Web Designer
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studiesTroubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Tier1 app
 
Medical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk ScoringMedical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk Scoring
ICS
 
Exchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv SoftwareExchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv Software
Shoviv Software
 
NYC ACE 08-May-2025-Combined Presentation.pdf
NYC ACE 08-May-2025-Combined Presentation.pdfNYC ACE 08-May-2025-Combined Presentation.pdf
NYC ACE 08-May-2025-Combined Presentation.pdf
AUGNYC
 
How I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetryHow I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetry
Cees Bos
 
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.pptPassive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
IES VE
 
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint PresentationFrom Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
Shay Ginsbourg
 
Robotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptxRobotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptx
julia smits
 
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdfTop Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
evrigsolution
 
Why Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card ProvidersWhy Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card Providers
Tapitag
 
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World ExamplesMastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
jamescantor38
 
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
Ranking Google
 
How to Install and Activate ListGrabber Plugin
How to Install and Activate ListGrabber PluginHow to Install and Activate ListGrabber Plugin
How to Install and Activate ListGrabber Plugin
eGrabber
 
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb ClarkDeploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Peter Caitens
 
AEM User Group DACH - 2025 Inaugural Meeting
AEM User Group DACH - 2025 Inaugural MeetingAEM User Group DACH - 2025 Inaugural Meeting
AEM User Group DACH - 2025 Inaugural Meeting
jennaf3
 
What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?
HireME
 
Beyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraftBeyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraft
Dmitrii Ivanov
 
[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts
Dimitrios Platis
 
Download 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-ActivatedDownload 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-Activated
Web Designer
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studiesTroubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Tier1 app
 
Medical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk ScoringMedical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk Scoring
ICS
 
Exchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv SoftwareExchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv Software
Shoviv Software
 
NYC ACE 08-May-2025-Combined Presentation.pdf
NYC ACE 08-May-2025-Combined Presentation.pdfNYC ACE 08-May-2025-Combined Presentation.pdf
NYC ACE 08-May-2025-Combined Presentation.pdf
AUGNYC
 
How I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetryHow I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetry
Cees Bos
 
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.pptPassive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
IES VE
 
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint PresentationFrom Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
Shay Ginsbourg
 
Robotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptxRobotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptx
julia smits
 
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdfTop Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
evrigsolution
 
Why Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card ProvidersWhy Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card Providers
Tapitag
 
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World ExamplesMastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
jamescantor38
 
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
Ranking Google
 
How to Install and Activate ListGrabber Plugin
How to Install and Activate ListGrabber PluginHow to Install and Activate ListGrabber Plugin
How to Install and Activate ListGrabber Plugin
eGrabber
 
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb ClarkDeploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Peter Caitens
 
AEM User Group DACH - 2025 Inaugural Meeting
AEM User Group DACH - 2025 Inaugural MeetingAEM User Group DACH - 2025 Inaugural Meeting
AEM User Group DACH - 2025 Inaugural Meeting
jennaf3
 
What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?
HireME
 
Beyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraftBeyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraft
Dmitrii Ivanov
 
Ad

Introduction to Domain driven design

  • 2. Domain Driven Design (DDD) Muhammad Ali Software Architect VentureDive
  • 3. Conway's law “Any organization that designs a system (defined more broadly here than just information systems) will inevitably produce a design whose structure is a copy of the organization's communication structure.”
  • 4. What is domain-driven design ● Domain-Driven Design is an approach to the development of complex software in which we: ○ Focus on core domain ○ Explore models in a creative collaboration of domain practitioners and software practitioners ○ Speak a ubiquitous language with in an explicitly bounded context
  • 5. Goal ● A domain specific project that needs to leverage multiple realms of expertise specifically ○ Design and Developer expertise ○ Domain specific expertise
  • 6. Complication ● Most of the times developers speak in terms of Objects, composition, aggregation, inheritance, polymorphism, pure functions etc. ● They talk more about technical solution rather than the problem itself. ● At times they don’t understand the underlying complexity and overcommit. ● Domain expert don’t know any of these, he has his own jargons regarding the domain. ● For example marketing people talking about leads, ads, campaigns, budgeting units etc. ● Similarly domain expert in airline talking about crew planning, SAFE, roster planning, FBO, PFA etc.
  • 7. Solution ● Strengthen the communication process and establish a methodology for making those communication more robust ● This is primarily accomplished by developing a UBIQUITOUS LANGUAGE and single model ● Make sure your developers speak this ubiquitous language. ● Persistent use of the UBIQUITOUS LANGUAGE will force the model's weaknesses into the open ● Building a language like this has a clear outcome: ○ Language and model are strongly interconnected with each other ○ Any changes to the language will be recognized as changes in the domain model
  • 8. Domain Model ● A system of abstraction that describes selected aspects of a domain and can be used to solve problems related to that domain. ● A domain model in not a particular(UML) diagram(unlike Model-Driven Design), it is the idea that diagram is intended to convey. ● Model can be an expression in natural language, code or a diagram. ● Model is not a design artifact ● Model are the backbone of domain-driven design ● The model is distilled knowledge ● It is not just the knowledge in a domain expert's head; it is a rigorously organized and selective abstraction of that knowledge
  • 9. Implementation ● Once Domain Model is defined, you can identify different components based on their properties ● You can divide your solution into different layers(so called layered architecture, MVP, MVC etc) ● For example following we can break down our solution into following layers ○ Presentation Layer (UI or Rest/SOAP) ○ Application Layer (Define the jobs that software is supposed to do and direct the expressive domain objects to work out problems.) ○ Domain Layer(Contains Business Logic) ○ Infrastructure Layer(Provides generic technical capabilities, like message sending, persistence etc.) ● There can be multiple layers with different names however Domain-Driven design only requires domain layer.
  • 10. Entities ● An object defined primarily by its identity is called an Entity. ● Each entity must have an operational way of establishing its identity with another object ● An identifying attribute must be guaranteed to be unique within the system however that system is defined, even if distributed, even when objects are archived
  • 11. Value Objects ● An object that represents a descriptive aspect of the domain with no conceptual identity is called a Value Object. ● The attributes that make up a Value Object should form a conceptual whole ● Immutability should also be considered when designing Value Objects ● As long as a Value Object is immutable, change management is simple
  • 12. Services ● There are important domain operations that can't find a natural home in an Entity or Value Object ● A Service is an operation offered as an interface that stands alone in the model, without encapsulating state, as Entities and Value Objects do. ● Services are a common pattern in technical frameworks, but they can also apply in the domain layer. ● A good service has following characteristics ○ The interface is defined in terms of other elements of the domain model ○ The operation relates to a domain concept that is not a natural part of an Entity or Value Object.
  • 13. Aggregates ● An aggregate is a cluster of domain objects that can be treated as a single unit ● Aggregates are the basic element of transfer of data storage - you request to load or save whole aggregates. Transactions should not cross aggregate boundaries. ● An aggregate will have one of its component objects be the aggregate root. ● Any references from outside the aggregate should only go to the aggregate root. ● The root can thus ensure the integrity of the aggregate as a whole. ● A delete operation must remove everything within the aggregate boundary at once ● When a change to any object within the aggregate boundary is committed, all invariants of the whole aggregate must be satisfied. When a change to any object within the aggregate boundary is committed, all invariants of the whole aggregate must be satisfied.
  • 14. Bounded Context ● Bounded Context is a central pattern in Domain-Driven Design ● DDD deals with large models by dividing them into different Bounded Contexts and being explicit about their interrelationships ● Total unification of the domain model for a large system will not be feasible or cost-effective ● So instead DDD divides up a large system into Bounded Contexts, each of which can have a unified model
  • 15. Context Map ● An individual Bounded Context still does not provide a global view. The context of other models may still be vague and in flux ● Code reuse between Bounded Context is a hazard to be avoided. ● A Context Map is the overlap between project management and software design. ● A Context Map is a document which outlines the different Bounded Contexts and the relationships between them. ● The level of detail may vary. What it is important is that everyone working on the project shares and understands it.
  翻译: