SlideShare une entreprise Scribd logo
1  sur  75
Télécharger pour lire hors ligne
Modelling a complex domain
with Domain-Driven Design
@NaeemSarfraz
#DDDesign #LeedsSharp
Can you tell me what is the
problem you’re trying to solve?
Is it possible to write code that
reflects the problem domain?
Could you deduce the original
requirements from your code?
Who am I?
Solutions Architect @ Barrett Steel
10+ years .NET Developer
Learn(new Things()).Like()
Play(Archery).Add(Horseriding).Like()
@NaeemSarfraz
http://naeemsarfraz.net
Silver Bullet Warning
Let’s Talk About Design…
▪ Do you do it?
▪ Big-Design-Up-Front vs Emergent Design
▪ “Working software over comprehensive documentation”
[Agile Manifesto]
▪ “Continuous attention to technical excellence and good
design enhances agility”
[Principles behind the Agile Manifesto]
▪ While we must acknowledge emergence in design and
system development, a little planning can avoid much
waste
[James Coplien, Lean Architecture]
Domain-Driven Design
What Is Domain-Driven Design?
1. Focus on the core complexity and opportunity
in the domain
2. Explore models in a collaboration of domain
experts and software experts
3. Write software that expresses those models
explicitly
4. Speak a ubiquitous language within a bounded
context
Correct Hashtag: #DDDesign
!#DDD
The Problem You’re Trying to Solve
▪ Complexity inherent in software
▪ Essential & Accidental complexity
▪ “That’s not what I meant” [An End User]
Definitions…
Problem Domain
▪ A sphere of knowledge, influence, or
activity
▪ The subject area to which the user
applies a program
Language
▪ The primary cause of misunderstanding between business &
development teams
▪ Agree and define key conceptsprocessesactors – a shared
vocabulary
▪ Avoid translations
▪ Language is reflected in code
▪ Who?
– Domain Expert (not a Product Owner)
– Development Team
Definitions…
Ubiquitous Language
▪ A language structured around the domain
model and used by all team members
within a bounded context to connect all
the activities of the team with the
software
Context
▪ Language has a meaning within a context
▪ A Model only has meaning within a context
▪ One Model to rule them all!
▪ Systems serve different user communities
▪ Define the context within which a model applies
– Library Loans
▪ Borrower of a Book
– Library Fines
▪ Member of a Library
Definitions…
Bounded Context
▪ A description of a boundary (typically a
subsystem, or the work of a particular
team) within which a particular model is
defined and applicable
Modelling
▪ Start with the key concepts in your problem domain
▪ Explore the interactions between these conceptsclasses
▪ Domain Model expressed as an Object Model
▪ Turn key concepts into pertinent classes
▪ Useful models not necessarily realistic
▪ Key: Domain-centric model not Data-centric
Definitions…
Model
▪ A system of abstractions that describes
selected aspects of a domain and can be
used to solve problems related to that
domain
Domain Model
▪ An object model of the domain that
incorporates both behaviour and data
Our Problem Domain
▪ As a Purchaser I want to be able to request to purchase goods
for independent depots So that I can purchase goods on behalf
of each specific business
▪ As a Purchaser I want to be able to request to purchase goods
that are required for multiple depots So that I can reduce the
amount of time taken to raise purchase orders required for each
depot
▪ As a Manager I want to be able to approve or reject a purchase
request So that we can follow the defined business approval
process
▪ As a Purchaser I want to be able to self-approve an order with
my self-approval limit So that I can purchase items which
require no approval
What are the Key Concepts?
The core domain is the part of
the domain most closely
associated with the strategy of
the company
Core Domain
Purpose Alignment Model
MarketDifferentiation
Mission Critical
Does anyone care?
Invest
Parity
Partner
Partner – Do we need
to take this on? Find
a partner
Parity – Achieve and
maintain parity
Invest – Excel and
innovate here, support
USP
Core Domain
Supporting
Sub-Domain
Generic
Sub-Domain
Entities
▪ An individual “thing”
▪ Has an identity
▪ Has a life
▪ Mutable
▪ Equality comparison using identity
Value Objects
▪ “Primitive Obsession”
▪ Doesn’t have an identity
▪ Equality comparison using properties
▪ Immutable
A Word About Immutability
▪ More Immutable structures = betterreliable code
▪ Type safety
▪ Side-effect free
▪ Try to move behavioural responsibilities into Value Objects
▪ Keep management of state in the Entity
Definitions…
Entities
▪ Objects that have a distinct identity
that runs through time and different
representations
Value Objects
▪ A small simple object, like money or a
date range, whose equality isn't based on
identity
Beware of Anti-Patterns
▪ Anaemic Domain Model
▪ The Leaky Model
▪ Partially Initialised Entities
Domain Services
▪ Sometimes, it just isn’t a thing
▪ First class citizens so name is part of Ubiquitous Language
▪ Exposed as a service
▪ A stateless operation
▪ Examples:
– LoanAnItem
– PlaceReservation
▪ Not an Application Service
– IEmailSender
– These depend on Infrastructure
Domain Events
▪ Something happened that the domain expert cares about
▪ First class citizens so name is part of Ubiquitous Language
▪ Named in the past tense e.g. ItemWasLoanedEvent
▪ Immutable – a record of something in the past
Definitions…
Domain Service
▪ A processtransformation in the domain
that is not a natural responsibility of an
entity or a value object
Domain Events
▪ A full-fledged part of the domain model, a
representation of something that happened
in the domain
Aggregates
▪ Collection of Entities and Value Objects treated as a conceptual
whole
▪ Root Entity is the Aggregate’s conceptual name
▪ Business defines the invariants
▪ External references are restricted to the root only
▪ Smaller the better
▪ Consistency:
– Logically consistent within an Aggregate via transaction
– Eventually consistent across Aggregates via propagating updates async
▪ Repository used to load and save an Aggregate
Definitions…
Aggregate
▪ A cluster of associated objects that are
treated as a unit for the purpose of
data changes
Presentation Layer
Business Layer
Data Access Layer
Data Storage Layer
Loans Context
Fines Context
Loan
Aggregate
Account
Aggregate
Book
Returned
Visual Studio time…
Model Exploration Whirlpool
▪ Start with a reference scenario
▪ Propose a model
▪ Code probe
▪ Repeat
Event Storming
▪ Take one big room with lots of clear surfaces
▪ Add Domain Experts and Developers
▪ Give them lots of sticky notes & sharpies (trust me you’ll
need lots)
▪ And get them to…talk?
Time
Book
Reserved
Book
Returned
Member
Pays
Money
Book
Loaned Fine Paid
Lorem
Ipsum
Dolored
Lorem
Ipsum
Dolored
Lorem
Ipsum
Dolored
Lorem
Ipsum
Dolored
Lorem
Ipsum
Dolored
Can we
pay
later?
Lorem
Ipsum
Dolored
What’s if
the book
is never
available
Places
Reservation
Can we
pay half
the fine?
In Summary
In Summary
▪ Knowing when to use it
▪ Domain centric modelling not data centric
▪ Work with your Domain Experts
▪ Give OO Design another chance
▪ Use Value Objects
▪ Do some f@*?ing design
Thank You
Any Questions?
t: @NaeemSarfraz
e: Naeem.Sarfraz@gmail.com
Follow up…
Events
▪ DDD Europe 2017 - Amsterdam
– https://dddeurope.com/2017
▪ DDDx 2017 – London
– https://skillsmatter.com
Pluralsight
▪ Domain-Driven Design in
Practise
▪ Domain-Driven Design
Fundamentals

Contenu connexe

Tendances

Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignNader Albert
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignRyan Riley
 
Domain Driven Design Demonstrated
Domain Driven Design Demonstrated Domain Driven Design Demonstrated
Domain Driven Design Demonstrated Alan Christensen
 
Applying Domain-Driven Design to craft Rich Domain Models
Applying Domain-Driven Design to craft Rich Domain ModelsApplying Domain-Driven Design to craft Rich Domain Models
Applying Domain-Driven Design to craft Rich Domain ModelsAlexander van Trijffel
 
Domain Driven Design Quickly
Domain Driven Design QuicklyDomain Driven Design Quickly
Domain Driven Design QuicklyMariam Hakobyan
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)Tom Kocjan
 
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
 
A Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation SlidesA Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation Slidesthinkddd
 
Domain Driven Design - Strategic Patterns and Microservices
Domain Driven Design - Strategic Patterns and MicroservicesDomain Driven Design - Strategic Patterns and Microservices
Domain Driven Design - Strategic Patterns and MicroservicesRadosław Maziarka
 
How to Implement Domain Driven Design in Real Life SDLC
How to Implement Domain Driven Design  in Real Life SDLCHow to Implement Domain Driven Design  in Real Life SDLC
How to Implement Domain Driven Design in Real Life SDLCAbdul Karim
 
Domain driven design
Domain driven designDomain driven design
Domain driven designtatyaso
 
Refactoring for Domain Driven Design
Refactoring for Domain Driven DesignRefactoring for Domain Driven Design
Refactoring for Domain Driven DesignDavid Berliner
 
Hexagonal architecture for java applications
Hexagonal architecture for java applicationsHexagonal architecture for java applications
Hexagonal architecture for java applicationsFabricio Epaminondas
 
Implementing DDD with C#
Implementing DDD with C#Implementing DDD with C#
Implementing DDD with C#Pascal Laurin
 
Domain Driven Design and Hexagonal Architecture
Domain Driven Design and Hexagonal ArchitectureDomain Driven Design and Hexagonal Architecture
Domain Driven Design and Hexagonal ArchitectureCrishantha Nanayakkara
 
Strategic Domain-Driven Design by Nick Tune at #AgileIndia2019
Strategic Domain-Driven Design by Nick Tune at #AgileIndia2019Strategic Domain-Driven Design by Nick Tune at #AgileIndia2019
Strategic Domain-Driven Design by Nick Tune at #AgileIndia2019Agile India
 

Tendances (20)

Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Domain Driven Design
Domain Driven Design Domain Driven Design
Domain Driven Design
 
Domain Driven Design Demonstrated
Domain Driven Design Demonstrated Domain Driven Design Demonstrated
Domain Driven Design Demonstrated
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Applying Domain-Driven Design to craft Rich Domain Models
Applying Domain-Driven Design to craft Rich Domain ModelsApplying Domain-Driven Design to craft Rich Domain Models
Applying Domain-Driven Design to craft Rich Domain Models
 
Domain Driven Design Quickly
Domain Driven Design QuicklyDomain Driven Design Quickly
Domain Driven Design Quickly
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
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
 
A Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation SlidesA Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation Slides
 
Domain Driven Design 101
Domain Driven Design 101Domain Driven Design 101
Domain Driven Design 101
 
Domain Driven Design - Strategic Patterns and Microservices
Domain Driven Design - Strategic Patterns and MicroservicesDomain Driven Design - Strategic Patterns and Microservices
Domain Driven Design - Strategic Patterns and Microservices
 
How to Implement Domain Driven Design in Real Life SDLC
How to Implement Domain Driven Design  in Real Life SDLCHow to Implement Domain Driven Design  in Real Life SDLC
How to Implement Domain Driven Design in Real Life SDLC
 
Domain driven design
Domain driven designDomain driven design
Domain driven design
 
Refactoring for Domain Driven Design
Refactoring for Domain Driven DesignRefactoring for Domain Driven Design
Refactoring for Domain Driven Design
 
Hexagonal architecture for java applications
Hexagonal architecture for java applicationsHexagonal architecture for java applications
Hexagonal architecture for java applications
 
Implementing DDD with C#
Implementing DDD with C#Implementing DDD with C#
Implementing DDD with C#
 
Domain Driven Design and Hexagonal Architecture
Domain Driven Design and Hexagonal ArchitectureDomain Driven Design and Hexagonal Architecture
Domain Driven Design and Hexagonal Architecture
 
Strategic Domain-Driven Design by Nick Tune at #AgileIndia2019
Strategic Domain-Driven Design by Nick Tune at #AgileIndia2019Strategic Domain-Driven Design by Nick Tune at #AgileIndia2019
Strategic Domain-Driven Design by Nick Tune at #AgileIndia2019
 

En vedette

Designing APIs and Microservices Using Domain-Driven Design
Designing APIs and Microservices Using Domain-Driven DesignDesigning APIs and Microservices Using Domain-Driven Design
Designing APIs and Microservices Using Domain-Driven DesignLaunchAny
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design IntroductionTung Nguyen Thanh
 
Designing For Your Least Able User
Designing For Your Least Able UserDesigning For Your Least Able User
Designing For Your Least Able Userfantasticlife
 
Mike Atherton - Domain modelling at the BBC
Mike Atherton - Domain modelling at the BBCMike Atherton - Domain modelling at the BBC
Mike Atherton - Domain modelling at the BBClightningUX
 
Domain Modelling
Domain ModellingDomain Modelling
Domain Modellingkim.mens
 
How We Make Websites
How We Make WebsitesHow We Make Websites
How We Make Websitesfantasticlife
 
Building Event Driven Systems
Building Event Driven SystemsBuilding Event Driven Systems
Building Event Driven SystemsWSO2
 
Domain-Driven Design at ZendCon 2012
Domain-Driven Design at ZendCon 2012Domain-Driven Design at ZendCon 2012
Domain-Driven Design at ZendCon 2012Bradley Holt
 
Domain-Driven Design: The "What" and the "Why"
Domain-Driven Design: The "What" and the "Why"Domain-Driven Design: The "What" and the "Why"
Domain-Driven Design: The "What" and the "Why"bincangteknologi
 
Domain-Driven Design workshops
Domain-Driven Design workshopsDomain-Driven Design workshops
Domain-Driven Design workshopsMariusz Kopylec
 
Domain-Driven Design und Hexagonale Architektur
Domain-Driven Design und Hexagonale ArchitekturDomain-Driven Design und Hexagonale Architektur
Domain-Driven Design und Hexagonale ArchitekturTorben Fojuth
 
Domain driven design
Domain driven designDomain driven design
Domain driven designjstack
 
An Introduction to Domain Driven Design for Product Managers
An Introduction to Domain Driven Design for Product ManagersAn Introduction to Domain Driven Design for Product Managers
An Introduction to Domain Driven Design for Product Managersr4isstatic
 
Agile development and domain driven design
Agile development and domain driven designAgile development and domain driven design
Agile development and domain driven designJacopo Romei
 
ZendCon 2011 UnCon Domain-Driven Design
ZendCon 2011 UnCon Domain-Driven DesignZendCon 2011 UnCon Domain-Driven Design
ZendCon 2011 UnCon Domain-Driven DesignBradley Holt
 
Domain-driven design - tactical patterns
Domain-driven design - tactical patternsDomain-driven design - tactical patterns
Domain-driven design - tactical patternsTom Janssens
 
Introduction to Domain Driven Design
Introduction to Domain Driven DesignIntroduction to Domain Driven Design
Introduction to Domain Driven DesignChristos Tsakostas
 

En vedette (20)

Designing APIs and Microservices Using Domain-Driven Design
Designing APIs and Microservices Using Domain-Driven DesignDesigning APIs and Microservices Using Domain-Driven Design
Designing APIs and Microservices Using Domain-Driven Design
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
 
Designing For Your Least Able User
Designing For Your Least Able UserDesigning For Your Least Able User
Designing For Your Least Able User
 
Mike Atherton - Domain modelling at the BBC
Mike Atherton - Domain modelling at the BBCMike Atherton - Domain modelling at the BBC
Mike Atherton - Domain modelling at the BBC
 
Domain Modelling
Domain ModellingDomain Modelling
Domain Modelling
 
How We Make Websites
How We Make WebsitesHow We Make Websites
How We Make Websites
 
Building Event Driven Systems
Building Event Driven SystemsBuilding Event Driven Systems
Building Event Driven Systems
 
Domain-Driven Design at ZendCon 2012
Domain-Driven Design at ZendCon 2012Domain-Driven Design at ZendCon 2012
Domain-Driven Design at ZendCon 2012
 
Domain-Driven Design: The "What" and the "Why"
Domain-Driven Design: The "What" and the "Why"Domain-Driven Design: The "What" and the "Why"
Domain-Driven Design: The "What" and the "Why"
 
Domain-Driven Design workshops
Domain-Driven Design workshopsDomain-Driven Design workshops
Domain-Driven Design workshops
 
Domain-Driven Design und Hexagonale Architektur
Domain-Driven Design und Hexagonale ArchitekturDomain-Driven Design und Hexagonale Architektur
Domain-Driven Design und Hexagonale Architektur
 
Domain driven design
Domain driven designDomain driven design
Domain driven design
 
An Introduction to Domain Driven Design for Product Managers
An Introduction to Domain Driven Design for Product ManagersAn Introduction to Domain Driven Design for Product Managers
An Introduction to Domain Driven Design for Product Managers
 
What is DDD and how could it help you
What is DDD and how could it help youWhat is DDD and how could it help you
What is DDD and how could it help you
 
Agile development and domain driven design
Agile development and domain driven designAgile development and domain driven design
Agile development and domain driven design
 
ZendCon 2011 UnCon Domain-Driven Design
ZendCon 2011 UnCon Domain-Driven DesignZendCon 2011 UnCon Domain-Driven Design
ZendCon 2011 UnCon Domain-Driven Design
 
Domain-driven design - tactical patterns
Domain-driven design - tactical patternsDomain-driven design - tactical patterns
Domain-driven design - tactical patterns
 
From legacy to DDD
From legacy to DDDFrom legacy to DDD
From legacy to DDD
 
Introduction to Domain Driven Design
Introduction to Domain Driven DesignIntroduction to Domain Driven Design
Introduction to Domain Driven Design
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 

Similaire à Modelling a complex domain with Domain-Driven Design

Code & Cannoli - Domain Driven Design
Code & Cannoli - Domain Driven DesignCode & Cannoli - Domain Driven Design
Code & Cannoli - Domain Driven DesignFrank Levering
 
Domain driven design: a gentle introduction
Domain driven design:  a gentle introductionDomain driven design:  a gentle introduction
Domain driven design: a gentle introductionAsher Sterkin
 
Schibsted Spain - Day 1 - DDD Course
Schibsted Spain - Day 1 - DDD CourseSchibsted Spain - Day 1 - DDD Course
Schibsted Spain - Day 1 - DDD CourseKevin Mas Ruiz
 
Domain Driven Design @ NewStore
Domain Driven Design @ NewStoreDomain Driven Design @ NewStore
Domain Driven Design @ NewStoreBernardo Torres
 
D2 domain driven-design
D2 domain driven-designD2 domain driven-design
D2 domain driven-designArnaud Bouchez
 
Structured Authoring for Business-Critical Content
Structured Authoring for Business-Critical ContentStructured Authoring for Business-Critical Content
Structured Authoring for Business-Critical ContentLavaCon
 
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
Seminar - Scalable Enterprise Application Development Using DDD and CQRSSeminar - Scalable Enterprise Application Development Using DDD and CQRS
Seminar - Scalable Enterprise Application Development Using DDD and CQRSMizanur Sarker
 
"How do I Architect?" - Quick Introduction to Architecture for Salesforce Ad...
"How do I Architect?"  - Quick Introduction to Architecture for Salesforce Ad..."How do I Architect?"  - Quick Introduction to Architecture for Salesforce Ad...
"How do I Architect?" - Quick Introduction to Architecture for Salesforce Ad...Steven Herod
 
Behavior Driven Development
Behavior Driven DevelopmentBehavior Driven Development
Behavior Driven DevelopmentNETUserGroupBern
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignLalit Kale
 
2011 iska - tim m - domain driven design
2011   iska - tim m - domain driven design2011   iska - tim m - domain driven design
2011 iska - tim m - domain driven designTim Mahy
 
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
 
Cloud Enablement Engine Role Definition and Mapping
Cloud Enablement Engine Role Definition and MappingCloud Enablement Engine Role Definition and Mapping
Cloud Enablement Engine Role Definition and MappingTom Laszewski
 
How I ended up contributing to Magento core
How I ended up contributing to Magento coreHow I ended up contributing to Magento core
How I ended up contributing to Magento coreAlessandro Ronchi
 
Beyond rails new
Beyond rails newBeyond rails new
Beyond rails newPaul Oguda
 

Similaire à Modelling a complex domain with Domain-Driven Design (20)

Code & Cannoli - Domain Driven Design
Code & Cannoli - Domain Driven DesignCode & Cannoli - Domain Driven Design
Code & Cannoli - Domain Driven Design
 
Domain driven design: a gentle introduction
Domain driven design:  a gentle introductionDomain driven design:  a gentle introduction
Domain driven design: a gentle introduction
 
Schibsted Spain - Day 1 - DDD Course
Schibsted Spain - Day 1 - DDD CourseSchibsted Spain - Day 1 - DDD Course
Schibsted Spain - Day 1 - DDD Course
 
RSG Sri Lanka Presentation - Ravindra Perera- Public Version.pdf
RSG Sri Lanka Presentation - Ravindra Perera- Public Version.pdfRSG Sri Lanka Presentation - Ravindra Perera- Public Version.pdf
RSG Sri Lanka Presentation - Ravindra Perera- Public Version.pdf
 
Into the domain
Into the domainInto the domain
Into the domain
 
Domain Driven Design @ NewStore
Domain Driven Design @ NewStoreDomain Driven Design @ NewStore
Domain Driven Design @ NewStore
 
D2 domain driven-design
D2 domain driven-designD2 domain driven-design
D2 domain driven-design
 
Structured Authoring for Business-Critical Content
Structured Authoring for Business-Critical ContentStructured Authoring for Business-Critical Content
Structured Authoring for Business-Critical Content
 
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
Seminar - Scalable Enterprise Application Development Using DDD and CQRSSeminar - Scalable Enterprise Application Development Using DDD and CQRS
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
 
L05 Design Patterns
L05 Design PatternsL05 Design Patterns
L05 Design Patterns
 
"How do I Architect?" - Quick Introduction to Architecture for Salesforce Ad...
"How do I Architect?"  - Quick Introduction to Architecture for Salesforce Ad..."How do I Architect?"  - Quick Introduction to Architecture for Salesforce Ad...
"How do I Architect?" - Quick Introduction to Architecture for Salesforce Ad...
 
Behavior Driven Development
Behavior Driven DevelopmentBehavior Driven Development
Behavior Driven Development
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
2011 iska - tim m - domain driven design
2011   iska - tim m - domain driven design2011   iska - tim m - domain driven design
2011 iska - tim m - 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
 
Designing DDD Aggregates
Designing DDD AggregatesDesigning DDD Aggregates
Designing DDD Aggregates
 
Cloud Enablement Engine Role Definition and Mapping
Cloud Enablement Engine Role Definition and MappingCloud Enablement Engine Role Definition and Mapping
Cloud Enablement Engine Role Definition and Mapping
 
How I ended up contributing to Magento core
How I ended up contributing to Magento coreHow I ended up contributing to Magento core
How I ended up contributing to Magento core
 
Beyond rails new
Beyond rails newBeyond rails new
Beyond rails new
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 

Dernier

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
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
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
+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
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
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
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
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
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...masabamasaba
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durbanmasabamasaba
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...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
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
%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
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 

Dernier (20)

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
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
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
+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...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
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
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
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
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%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
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%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
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 

Modelling a complex domain with Domain-Driven Design

  • 1. Modelling a complex domain with Domain-Driven Design @NaeemSarfraz #DDDesign #LeedsSharp
  • 2.
  • 3.
  • 4. Can you tell me what is the problem you’re trying to solve?
  • 5.
  • 6. Is it possible to write code that reflects the problem domain?
  • 7. Could you deduce the original requirements from your code?
  • 8. Who am I? Solutions Architect @ Barrett Steel 10+ years .NET Developer Learn(new Things()).Like() Play(Archery).Add(Horseriding).Like() @NaeemSarfraz http://naeemsarfraz.net
  • 10. Let’s Talk About Design… ▪ Do you do it? ▪ Big-Design-Up-Front vs Emergent Design ▪ “Working software over comprehensive documentation” [Agile Manifesto] ▪ “Continuous attention to technical excellence and good design enhances agility” [Principles behind the Agile Manifesto] ▪ While we must acknowledge emergence in design and system development, a little planning can avoid much waste [James Coplien, Lean Architecture]
  • 11.
  • 12.
  • 13.
  • 15. What Is Domain-Driven Design? 1. Focus on the core complexity and opportunity in the domain 2. Explore models in a collaboration of domain experts and software experts 3. Write software that expresses those models explicitly 4. Speak a ubiquitous language within a bounded context
  • 16.
  • 18.
  • 19. The Problem You’re Trying to Solve ▪ Complexity inherent in software ▪ Essential & Accidental complexity ▪ “That’s not what I meant” [An End User]
  • 20. Definitions… Problem Domain ▪ A sphere of knowledge, influence, or activity ▪ The subject area to which the user applies a program
  • 21. Language ▪ The primary cause of misunderstanding between business & development teams ▪ Agree and define key conceptsprocessesactors – a shared vocabulary ▪ Avoid translations ▪ Language is reflected in code ▪ Who? – Domain Expert (not a Product Owner) – Development Team
  • 22. Definitions… Ubiquitous Language ▪ A language structured around the domain model and used by all team members within a bounded context to connect all the activities of the team with the software
  • 23. Context ▪ Language has a meaning within a context ▪ A Model only has meaning within a context ▪ One Model to rule them all! ▪ Systems serve different user communities ▪ Define the context within which a model applies – Library Loans ▪ Borrower of a Book – Library Fines ▪ Member of a Library
  • 24. Definitions… Bounded Context ▪ A description of a boundary (typically a subsystem, or the work of a particular team) within which a particular model is defined and applicable
  • 25. Modelling ▪ Start with the key concepts in your problem domain ▪ Explore the interactions between these conceptsclasses ▪ Domain Model expressed as an Object Model ▪ Turn key concepts into pertinent classes ▪ Useful models not necessarily realistic ▪ Key: Domain-centric model not Data-centric
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32. Definitions… Model ▪ A system of abstractions that describes selected aspects of a domain and can be used to solve problems related to that domain Domain Model ▪ An object model of the domain that incorporates both behaviour and data
  • 33. Our Problem Domain ▪ As a Purchaser I want to be able to request to purchase goods for independent depots So that I can purchase goods on behalf of each specific business ▪ As a Purchaser I want to be able to request to purchase goods that are required for multiple depots So that I can reduce the amount of time taken to raise purchase orders required for each depot ▪ As a Manager I want to be able to approve or reject a purchase request So that we can follow the defined business approval process ▪ As a Purchaser I want to be able to self-approve an order with my self-approval limit So that I can purchase items which require no approval
  • 34. What are the Key Concepts?
  • 35.
  • 36.
  • 37.
  • 38.
  • 39. The core domain is the part of the domain most closely associated with the strategy of the company Core Domain
  • 40. Purpose Alignment Model MarketDifferentiation Mission Critical Does anyone care? Invest Parity Partner Partner – Do we need to take this on? Find a partner Parity – Achieve and maintain parity Invest – Excel and innovate here, support USP Core Domain Supporting Sub-Domain Generic Sub-Domain
  • 41.
  • 42.
  • 43. Entities ▪ An individual “thing” ▪ Has an identity ▪ Has a life ▪ Mutable ▪ Equality comparison using identity
  • 44. Value Objects ▪ “Primitive Obsession” ▪ Doesn’t have an identity ▪ Equality comparison using properties ▪ Immutable
  • 45. A Word About Immutability ▪ More Immutable structures = betterreliable code ▪ Type safety ▪ Side-effect free ▪ Try to move behavioural responsibilities into Value Objects ▪ Keep management of state in the Entity
  • 46.
  • 47.
  • 48.
  • 49. Definitions… Entities ▪ Objects that have a distinct identity that runs through time and different representations Value Objects ▪ A small simple object, like money or a date range, whose equality isn't based on identity
  • 50. Beware of Anti-Patterns ▪ Anaemic Domain Model ▪ The Leaky Model ▪ Partially Initialised Entities
  • 51. Domain Services ▪ Sometimes, it just isn’t a thing ▪ First class citizens so name is part of Ubiquitous Language ▪ Exposed as a service ▪ A stateless operation ▪ Examples: – LoanAnItem – PlaceReservation ▪ Not an Application Service – IEmailSender – These depend on Infrastructure
  • 52. Domain Events ▪ Something happened that the domain expert cares about ▪ First class citizens so name is part of Ubiquitous Language ▪ Named in the past tense e.g. ItemWasLoanedEvent ▪ Immutable – a record of something in the past
  • 53.
  • 54. Definitions… Domain Service ▪ A processtransformation in the domain that is not a natural responsibility of an entity or a value object Domain Events ▪ A full-fledged part of the domain model, a representation of something that happened in the domain
  • 55. Aggregates ▪ Collection of Entities and Value Objects treated as a conceptual whole ▪ Root Entity is the Aggregate’s conceptual name ▪ Business defines the invariants ▪ External references are restricted to the root only ▪ Smaller the better ▪ Consistency: – Logically consistent within an Aggregate via transaction – Eventually consistent across Aggregates via propagating updates async ▪ Repository used to load and save an Aggregate
  • 56. Definitions… Aggregate ▪ A cluster of associated objects that are treated as a unit for the purpose of data changes
  • 57. Presentation Layer Business Layer Data Access Layer Data Storage Layer
  • 58.
  • 59.
  • 61.
  • 63. Model Exploration Whirlpool ▪ Start with a reference scenario ▪ Propose a model ▪ Code probe ▪ Repeat
  • 64.
  • 65. Event Storming ▪ Take one big room with lots of clear surfaces ▪ Add Domain Experts and Developers ▪ Give them lots of sticky notes & sharpies (trust me you’ll need lots) ▪ And get them to…talk?
  • 66. Time Book Reserved Book Returned Member Pays Money Book Loaned Fine Paid Lorem Ipsum Dolored Lorem Ipsum Dolored Lorem Ipsum Dolored Lorem Ipsum Dolored Lorem Ipsum Dolored Can we pay later? Lorem Ipsum Dolored What’s if the book is never available Places Reservation Can we pay half the fine?
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73. In Summary ▪ Knowing when to use it ▪ Domain centric modelling not data centric ▪ Work with your Domain Experts ▪ Give OO Design another chance ▪ Use Value Objects ▪ Do some f@*?ing design
  • 74. Thank You Any Questions? t: @NaeemSarfraz e: Naeem.Sarfraz@gmail.com
  • 75. Follow up… Events ▪ DDD Europe 2017 - Amsterdam – https://dddeurope.com/2017 ▪ DDDx 2017 – London – https://skillsmatter.com Pluralsight ▪ Domain-Driven Design in Practise ▪ Domain-Driven Design Fundamentals