SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Intro to
Domain Driven
Design
Tackling Complexity in the Heart of Software
“Eric Evans' 2003 book is an essential read for serious software developers” -- Fowler
There are shorter book versions: “distilled”, “quickly”, “kompakt”, “implementing”, “easily”
WIIFM
â—Ź Get to know a development approach for complex domains
â—Ź Closer internal stakeholder collaboration
â—Ź Better architecture (loosely-coupled, cohesive)
â—‹ Easier to change
â—‹ Safer to change - less incidents due to inter-team misalignments
â—Ź Companies that exercise DDD were more successful for a long time
â—Ź Can be the basis of future breaking of a monolith
â—Ź Additional paths of refactoring, not only technical
Images from the DDD book and Martin Fowler’s website
Model
“All models are wrong, but some models are useful” -- George Box
Ubiquitous Language
â—Ź Have the same terminology: developers, POs, analysts, BI, CS, Designers, QAs
â—Ź In all deliverables: code, documentation, test cases, business cases, sales
â—Ź How? Requirements, talk to domain experts, capture business processes (e.g. event
storming), produce UML, data flow, use industry standards (a.k.a Published Language)
â—Ź Examples: User, Airport, Hotel, Hotel room booked
Isolating the domain in the code
Layered Architecture
â—Ź UI / API - expose data, receive commands
â—Ź Application - thin, delegates to domain objects
â—Ź Domain - business concepts and rules
â—Ź Infrastructure - generic technical capabilities
(email, messaging)
Building Blocks
â—Ź Entity
â—‹ Has identity, is persisted, is mutable
â—‹ Examples: marked bills, hotel
â—Ź Value Object
â—‹ Defined by its attributes, is immutable, depends on Entity
â—‹ Example: unmarked bills, company address
â—Ź Aggregate - group of entities and value objects.
â—‹ Example: Purchase (the root), invoice, transactions
â—Ź Service
â—‹ Domain business process, has no state
â—‹ Example: book a room
â—Ź Factory
â—‹ A common design pattern for encapsulating the building (non-trivial) objects
â—‹ Example: Computer object
Storing and retrieving (working with database)
â—Ź Repository (aggregates persistence)
A common persistence design pattern (in contrast to Rails’ ActiveRecord)
â—‹ Retrieve collections and associations
■ Example: retrieve all applications with status “pending” and their associated recruiters
○ Store “unit of work”
â–  Example: store a purchase with its invoice and transactions
â—Ź ORM (Object/Relational Mapping)
â—‹ Map between in-memory objects and the database
â—‹ Reduce cognitive load
Building Blocks Summary
Bounded Context
A “group” of related models and services with explicit interrelations, e.g. Sales and Support
Note that “Customer” exists in both contexts, but might be different models with translation.
Context Map - identify relationships between bounded contexts
Inter-Team relationships
â—Ź Shared kernel
â—Ź Customer-supplier
â—Ź Conformist
â—Ź Separate ways
â—Ź Anticorruption layer
Conway’s Law: Any organization that designs a system, will produce a design whose structure is a copy of the organization's communication
structure
Supple design - technical aspect to make constant changes easier
Distillation - defining subdomains
â—Ź Core Domain
â—‹ e.g. Performance Marketing on job boards
â—Ź Generic Subdomain
â—‹ e.g. User mgmt and permissions
â—Ź Supporting Subdomain
â—‹ e.g. Job lifecycle management
â—Ź Segregated core
â—‹ To refine a complex core domain
Additional terminology
â—Ź Domain Events
â—‹ Important events for domain experts (in code or not, inside bounded context or between)
â—Ź Event driven (architecture)
â—‹ Components react to events emitted to a messaging solution
â—Ź Event sourcing (architecture)
â—‹ Event driven where only events are stored, not current states
â—Ź Services / Microservices (architecture)
â—‹ Can compose a bounded context, also third party services
â—Ź Design patterns
â—‹ Examples: Anti corruption layer, composition, abstract factory, factory method, strategy,
adapter
â—Ź CQRS
â—‹ Objects that read are not the objects that write
Continuous refinement of the models
â—Ź Domain experts
â—Ź Knowledge crunching
â—Ź Continuous learning
â—Ź Refactoring
Common Anti-patterns
â—Ź Implicit communications between cores/bounded contexts thru database
â—Ź Coupling unrelated objects / decoupling related objects
â—Ź Hidden business rules (Utils, small methods)
â—Ź Business logic in wrong layers: UI / Controller / DB
Within Ruby and Rails Ecosystem
â—Ź Ruby Modules âś…
â—Ź MVC âś…
â—Ź Thin controllers, service objects âś…
â—Ź ActiveRecord X (but can build repositories that call ActiveRecord scopes)
â—Ź ORM âś…
â—Ź CI âś…
â—Ź Automated tests âś…
â—Ź Refactoring âś…
â—Ź Messaging solutions âś…
How to start?
â—Ź Read the book
â—Ź Give an internal tech talk
â—Ź Discuss with team members, other teams, stakeholders
â—Ź Talk to domain experts
â—Ź Have event storming
â—Ź Identify one bounded context, refactor into namespaces
â—Ź Limit direct communication to/from this bounded context
â—Ź Refactor from domain perspective, not only technical
How to start?
â—Ź Elevate domain concepts and create explicit policy objects (e.g. VAT)
â—Ź Move logic only into domain objects
â—Ź In architecture evolution, keep DDD in mind
Resources
â—Ź The DDD book
â—Ź Eric Evans Talk
â—Ź Object Oriented Software Construction - Bertrand Meyer
â—Ź Working Effectively with Legacy Code - Robert C. Martin
â—Ź Design Patterns. Elements of Reusable Object-Oriented
Software - Erich Gamma
â—Ź https://github.com/ddd-crew/ddd-starter-modelling-process
â—Ź CQRS

Weitere ähnliche Inhalte

Ă„hnlich wie Intro to Domain Driven Design

Clean architecture
Clean architectureClean architecture
Clean architecture.NET Crowd
 
Domain driven design: a gentle introduction
Domain driven design:  a gentle introductionDomain driven design:  a gentle introduction
Domain driven design: a gentle introductionAsher Sterkin
 
JavaScript for Enterprise Applications
JavaScript for Enterprise ApplicationsJavaScript for Enterprise Applications
JavaScript for Enterprise ApplicationsPiyush Katariya
 
Introduction to Domain driven design
Introduction to Domain driven designIntroduction to Domain driven design
Introduction to Domain driven designMuhammad Ali
 
Baby steps to Domain-Driven Design
Baby steps to Domain-Driven DesignBaby steps to Domain-Driven Design
Baby steps to Domain-Driven DesignŽilvinas Kuusas
 
Towards More Flexible Enterprise Information Systems
Towards More Flexible Enterprise Information SystemsTowards More Flexible Enterprise Information Systems
Towards More Flexible Enterprise Information SystemsCONFENIS 2012
 
Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Fwdays
 
Software architecture, Patterns for Scale
Software architecture, Patterns for ScaleSoftware architecture, Patterns for Scale
Software architecture, Patterns for ScaleiGbanam
 
Fighting legacy with hexagonal architecture and frameworkless php
Fighting legacy with hexagonal architecture and frameworkless phpFighting legacy with hexagonal architecture and frameworkless php
Fighting legacy with hexagonal architecture and frameworkless phpFabio Pellegrini
 
Brownfield Domain Driven Design
Brownfield Domain Driven DesignBrownfield Domain Driven Design
Brownfield Domain Driven DesignNicolò Pignatelli
 
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...PĂ´le Systematic Paris-Region
 
Enterprise PHP Architecture through Design Patterns and Modularization (Midwe...
Enterprise PHP Architecture through Design Patterns and Modularization (Midwe...Enterprise PHP Architecture through Design Patterns and Modularization (Midwe...
Enterprise PHP Architecture through Design Patterns and Modularization (Midwe...Aaron Saray
 
Prototyping Workshop - Wireframes, Mockups, Prototypes
Prototyping Workshop - Wireframes, Mockups, PrototypesPrototyping Workshop - Wireframes, Mockups, Prototypes
Prototyping Workshop - Wireframes, Mockups, PrototypesMarta Soncodi
 
Domain driven design and model driven development
Domain driven design and model driven developmentDomain driven design and model driven development
Domain driven design and model driven developmentDmitry Geyzersky
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven DesignGeeks Anonymes
 
Modelling a complex domain with Domain-Driven Design
Modelling a complex domain with Domain-Driven DesignModelling a complex domain with Domain-Driven Design
Modelling a complex domain with Domain-Driven DesignNaeem Sarfraz
 
DDD with Behat
DDD with BehatDDD with Behat
DDD with BehatAnton Serdyuk
 
MongoDB@sfr.fr
MongoDB@sfr.frMongoDB@sfr.fr
MongoDB@sfr.frbeboutou
 
Introduction to DDD
Introduction to DDDIntroduction to DDD
Introduction to DDDEduards Sizovs
 
Benefits of using software design patterns and when to use design pattern
Benefits of using software design patterns and when to use design patternBenefits of using software design patterns and when to use design pattern
Benefits of using software design patterns and when to use design patternBeroza Paul
 

Ă„hnlich wie Intro to Domain Driven Design (20)

Clean architecture
Clean architectureClean architecture
Clean architecture
 
Domain driven design: a gentle introduction
Domain driven design:  a gentle introductionDomain driven design:  a gentle introduction
Domain driven design: a gentle introduction
 
JavaScript for Enterprise Applications
JavaScript for Enterprise ApplicationsJavaScript for Enterprise Applications
JavaScript for Enterprise Applications
 
Introduction to Domain driven design
Introduction to Domain driven designIntroduction to Domain driven design
Introduction to Domain driven design
 
Baby steps to Domain-Driven Design
Baby steps to Domain-Driven DesignBaby steps to Domain-Driven Design
Baby steps to Domain-Driven Design
 
Towards More Flexible Enterprise Information Systems
Towards More Flexible Enterprise Information SystemsTowards More Flexible Enterprise Information Systems
Towards More Flexible Enterprise Information Systems
 
Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"
 
Software architecture, Patterns for Scale
Software architecture, Patterns for ScaleSoftware architecture, Patterns for Scale
Software architecture, Patterns for Scale
 
Fighting legacy with hexagonal architecture and frameworkless php
Fighting legacy with hexagonal architecture and frameworkless phpFighting legacy with hexagonal architecture and frameworkless php
Fighting legacy with hexagonal architecture and frameworkless php
 
Brownfield Domain Driven Design
Brownfield Domain Driven DesignBrownfield Domain Driven Design
Brownfield Domain Driven Design
 
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
 
Enterprise PHP Architecture through Design Patterns and Modularization (Midwe...
Enterprise PHP Architecture through Design Patterns and Modularization (Midwe...Enterprise PHP Architecture through Design Patterns and Modularization (Midwe...
Enterprise PHP Architecture through Design Patterns and Modularization (Midwe...
 
Prototyping Workshop - Wireframes, Mockups, Prototypes
Prototyping Workshop - Wireframes, Mockups, PrototypesPrototyping Workshop - Wireframes, Mockups, Prototypes
Prototyping Workshop - Wireframes, Mockups, Prototypes
 
Domain driven design and model driven development
Domain driven design and model driven developmentDomain driven design and model driven development
Domain driven design and model driven development
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven Design
 
Modelling a complex domain with Domain-Driven Design
Modelling a complex domain with Domain-Driven DesignModelling a complex domain with Domain-Driven Design
Modelling a complex domain with Domain-Driven Design
 
DDD with Behat
DDD with BehatDDD with Behat
DDD with Behat
 
MongoDB@sfr.fr
MongoDB@sfr.frMongoDB@sfr.fr
MongoDB@sfr.fr
 
Introduction to DDD
Introduction to DDDIntroduction to DDD
Introduction to DDD
 
Benefits of using software design patterns and when to use design pattern
Benefits of using software design patterns and when to use design patternBenefits of using software design patterns and when to use design pattern
Benefits of using software design patterns and when to use design pattern
 

KĂĽrzlich hochgeladen

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile EnvironmentVictorSzoltysek
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 

KĂĽrzlich hochgeladen (20)

Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 

Intro to Domain Driven Design

  • 1. Intro to Domain Driven Design Tackling Complexity in the Heart of Software “Eric Evans' 2003 book is an essential read for serious software developers” -- Fowler There are shorter book versions: “distilled”, “quickly”, “kompakt”, “implementing”, “easily”
  • 2. WIIFM â—Ź Get to know a development approach for complex domains â—Ź Closer internal stakeholder collaboration â—Ź Better architecture (loosely-coupled, cohesive) â—‹ Easier to change â—‹ Safer to change - less incidents due to inter-team misalignments â—Ź Companies that exercise DDD were more successful for a long time â—Ź Can be the basis of future breaking of a monolith â—Ź Additional paths of refactoring, not only technical Images from the DDD book and Martin Fowler’s website
  • 3. Model “All models are wrong, but some models are useful” -- George Box
  • 4. Ubiquitous Language â—Ź Have the same terminology: developers, POs, analysts, BI, CS, Designers, QAs â—Ź In all deliverables: code, documentation, test cases, business cases, sales â—Ź How? Requirements, talk to domain experts, capture business processes (e.g. event storming), produce UML, data flow, use industry standards (a.k.a Published Language) â—Ź Examples: User, Airport, Hotel, Hotel room booked
  • 5. Isolating the domain in the code Layered Architecture â—Ź UI / API - expose data, receive commands â—Ź Application - thin, delegates to domain objects â—Ź Domain - business concepts and rules â—Ź Infrastructure - generic technical capabilities (email, messaging)
  • 6. Building Blocks â—Ź Entity â—‹ Has identity, is persisted, is mutable â—‹ Examples: marked bills, hotel â—Ź Value Object â—‹ Defined by its attributes, is immutable, depends on Entity â—‹ Example: unmarked bills, company address â—Ź Aggregate - group of entities and value objects. â—‹ Example: Purchase (the root), invoice, transactions â—Ź Service â—‹ Domain business process, has no state â—‹ Example: book a room â—Ź Factory â—‹ A common design pattern for encapsulating the building (non-trivial) objects â—‹ Example: Computer object
  • 7. Storing and retrieving (working with database) â—Ź Repository (aggregates persistence) A common persistence design pattern (in contrast to Rails’ ActiveRecord) â—‹ Retrieve collections and associations â–  Example: retrieve all applications with status “pending” and their associated recruiters â—‹ Store “unit of work” â–  Example: store a purchase with its invoice and transactions â—Ź ORM (Object/Relational Mapping) â—‹ Map between in-memory objects and the database â—‹ Reduce cognitive load
  • 9. Bounded Context A “group” of related models and services with explicit interrelations, e.g. Sales and Support Note that “Customer” exists in both contexts, but might be different models with translation. Context Map - identify relationships between bounded contexts
  • 10. Inter-Team relationships â—Ź Shared kernel â—Ź Customer-supplier â—Ź Conformist â—Ź Separate ways â—Ź Anticorruption layer Conway’s Law: Any organization that designs a system, will produce a design whose structure is a copy of the organization's communication structure
  • 11. Supple design - technical aspect to make constant changes easier
  • 12. Distillation - defining subdomains â—Ź Core Domain â—‹ e.g. Performance Marketing on job boards â—Ź Generic Subdomain â—‹ e.g. User mgmt and permissions â—Ź Supporting Subdomain â—‹ e.g. Job lifecycle management â—Ź Segregated core â—‹ To refine a complex core domain
  • 13. Additional terminology â—Ź Domain Events â—‹ Important events for domain experts (in code or not, inside bounded context or between) â—Ź Event driven (architecture) â—‹ Components react to events emitted to a messaging solution â—Ź Event sourcing (architecture) â—‹ Event driven where only events are stored, not current states â—Ź Services / Microservices (architecture) â—‹ Can compose a bounded context, also third party services â—Ź Design patterns â—‹ Examples: Anti corruption layer, composition, abstract factory, factory method, strategy, adapter â—Ź CQRS â—‹ Objects that read are not the objects that write
  • 14. Continuous refinement of the models â—Ź Domain experts â—Ź Knowledge crunching â—Ź Continuous learning â—Ź Refactoring
  • 15. Common Anti-patterns â—Ź Implicit communications between cores/bounded contexts thru database â—Ź Coupling unrelated objects / decoupling related objects â—Ź Hidden business rules (Utils, small methods) â—Ź Business logic in wrong layers: UI / Controller / DB
  • 16. Within Ruby and Rails Ecosystem â—Ź Ruby Modules âś… â—Ź MVC âś… â—Ź Thin controllers, service objects âś… â—Ź ActiveRecord X (but can build repositories that call ActiveRecord scopes) â—Ź ORM âś… â—Ź CI âś… â—Ź Automated tests âś… â—Ź Refactoring âś… â—Ź Messaging solutions âś…
  • 17. How to start? â—Ź Read the book â—Ź Give an internal tech talk â—Ź Discuss with team members, other teams, stakeholders â—Ź Talk to domain experts â—Ź Have event storming â—Ź Identify one bounded context, refactor into namespaces â—Ź Limit direct communication to/from this bounded context â—Ź Refactor from domain perspective, not only technical
  • 18. How to start? â—Ź Elevate domain concepts and create explicit policy objects (e.g. VAT) â—Ź Move logic only into domain objects â—Ź In architecture evolution, keep DDD in mind
  • 19. Resources â—Ź The DDD book â—Ź Eric Evans Talk â—Ź Object Oriented Software Construction - Bertrand Meyer â—Ź Working Effectively with Legacy Code - Robert C. Martin â—Ź Design Patterns. Elements of Reusable Object-Oriented Software - Erich Gamma â—Ź https://github.com/ddd-crew/ddd-starter-modelling-process â—Ź CQRS