SlideShare a Scribd company logo
Domain Driven Design
Ubiquitous Language 
UbiquitousLanguage@Fowler's blog
Ubiquitous Language 
That’s all there is to it
Ubiquitous Language 
That’s all there is to it 
Questions?
Client 
(Domain expert) 
Project Manager Developer 
We need to add a new 
security policy to our 
accounts. Our customers 
can’t have more than two 
active offers per billing term. 
We need to restrict 
promotions. A user cannot 
have more than two 
promotions per month. 
public function validate(User $user) 
{ 
// … other crazy validations 
if (count ($user->getPromotions()) > 2) 
throw new ValidationException( 
“User can’t have more than 2 
promotions per month” 
); 
// … continue with crazy validations 
}
Favor model language 
over translations
Client 
(Domain expert) 
Project Manager Developer 
We need to add a new 
security policy to our 
accounts. Our customers 
can’t have more than two 
active offers per billing term. 
public function validate(Account $account) 
{ 
// … other crazy validations 
if (! $account->satisfies( 
new ActiveOffersPerBillingTermSecurityPolicy 
)) 
throw new ValidationException( 
“Account did not satisfy the active offers 
security policy” 
); 
// … continue with crazy validations 
}
ActiveOffersPerBillingTerm 
SecurityPolicy 
… really? 
TOO MUCH CODE! 
I WON’T TYPE THAT!!!11
Semantics
Semantics 
ActiveOffersPerBillingTermSecurityPolicy means something 
in the MODEL LANGUAGE 
count($user->getPromotions()) > 2 
does not convey this knowledge
Semantics 
ActiveOffersPerBillingTermSecurityPolicy means something 
in the MODEL LANGUAGE 
count($user->getPromotions()) > 2 
does not convey this knowledge 
=> MAKE IMPLICIT BUSINESS RULES EXPLICIT
Favor model language 
over translations 
When a domain expert (client) feels something’s wrong with the model 
language, you’ll know something’s wrong with the domain model.
Client 
(Domain expert) 
Project Manager Developer 
When we talk about a billing 
term, we need to consider if 
the customer is billed on a 
monthly or yearly basis. 
| class ActiveOffersPerBillingTermSecurityPolicy 
| { 
| protected $maxOffers = 2; 
| 
| public function isSatisfiedBy(Account $account) 
| { 
| return count( 
- | $account->getMonthlyOffers() 
+ | $account->getOffersForBillingTerm() 
| ) < $this->maxOffers; 
| }
Domain Knowledge
Domain Knowledge 
Focus your efforts in building a clear domain, 
specific to your client’s needs
Knowledge crunching
Client 
(Domain expert) 
class LongOverdueCustomerContactCommand 
{ 
public function execute() 
{ 
$customers = Customer::where( 
‘account.balance’, ‘<’, 0 
)->get(); 
foreach ($customers as $customer) 
$this->sendRefinanceEmail($customer); 
} 
} 
Project Manager Developer 
We need to contact long 
overdue customers to 
refinance their debt.
Client 
(Domain expert) 
class LongOverdueCustomerContactCommand 
{ 
public function execute() 
{ 
$customers = Customer::where( 
‘account.balance’, ‘<’, 0 
)->get(); 
foreach ($customers as $customer) 
$this->sendRefinanceEmail($customer); 
} 
} 
Project Manager Developer 
We need to contact long 
overdue customers to 
refinance their debt.
Client 
(Domain expert) 
Project Manager Developer 
We need to contact long 
overdue customers to 
refinance their debt. 
What is the difference 
between a regular customer, 
an overdue customer and a 
long overdue customer?
Client 
(Domain expert) 
class CustomerRepository 
{ 
public function findOverdue() 
{ 
return Customer::where(‘account.balance’, ‘<’, 0) 
->get(); 
} 
public function findLongOverdue() 
{ 
// Write more complex query logic for this one... 
} 
} 
Project Manager Developer 
Overdue is straightforward, 
customers in debt right now. 
Long overdue customers are 
the ones that have been 
overdue over the last 3 
billing terms, at the end of 
each billing term.
Knowledge crunching 
Knowledge crunching deepens the domain 
model, and brings better understanding
But… How?
Domain-oriented 
Design Patterns
class AccountsController 
{ 
public function index() 
{ 
$accounts = Account::all(); 
return View::make(‘accounts.index’, [ 
‘accounts’ => $accounts 
]); 
} 
}
class AccountsController 
{ 
public function index() 
{ 
$accounts = Account::all(); 
return View::make(‘accounts.index’, [ 
‘accounts’ => $accounts 
]); 
} 
}
EvansClassification@Fowler's blog
Entities
Entities 
Objects with an identity 
Lifespan 
Unique criteria
ValueObjects
ValueObjects 
Defined by their attributes
Aggregates
Aggregates 
Cluster of domain objects 
Transactional coherence
Services
Services 
Domain coordinators 
Define actions
Repositories
Repositories 
Data access abstraction
Factories
Factories 
Object creation
Domain Events
Domain Events 
Objects that represent significant domain 
events
Domain-oriented 
Architecture
Layered Architecture
Layered Architecture
Hexagonal Architecture
Hexagonal Architecture
Domain-oriented 
Architecture 
Isolate your domain model from 
specific application needs: 
UI - Persistence - External Services - 
Application workflow - etc...
So… What’s the point?
It’s not about writing 
code
It’s not about writing 
code 
That’s the easy part… right?
It’s not about writing 
code 
It’s about understanding what needs to be 
solved before starting to code
Creating a language which 
makes conversations 
between domain experts and 
developers possible without 
misinterpretations
Creating a language which 
makes conversations 
between domain experts and 
developers possible without 
(so many) misinterpretations
● Eric Evans, “Domain-Driven Design: Tackling Complexity in the Heart of Software” 
● Vaughn Vernon, “Implementing Domain-Driven Design” 
● Martin Fowler, “Patterns of Enterprise Application Architecture” 
● dddcommunity.org | Domain Driven Design Community 
● -http://domainlanguage.com/ddd/reference/DDD_Reference_2011-01-31.pdf 
● -http://www.lmgtfy.com/?q=Domain+Driven+Design

More Related Content

PPTX
Dependency injection - the right way
PPTX
Introduction to OO, Java and Eclipse/WebSphere
PPTX
Applying Code Customizations to Magento 2
PDF
Apex Enterprise Patterns: Building Strong Foundations
PDF
Building and deploying microservices with event sourcing, CQRS and Docker (QC...
PPTX
ELEVATE Advanced Workshop
PDF
Improving application design with a rich domain model (springone 2007)
PDF
Dependency Injection in Drupal 8
Dependency injection - the right way
Introduction to OO, Java and Eclipse/WebSphere
Applying Code Customizations to Magento 2
Apex Enterprise Patterns: Building Strong Foundations
Building and deploying microservices with event sourcing, CQRS and Docker (QC...
ELEVATE Advanced Workshop
Improving application design with a rich domain model (springone 2007)
Dependency Injection in Drupal 8

Similar to Introduction to Domain driven design (LaravelBA #5) (20)

PPT
Week 8
PDF
Building and deploying microservices with event sourcing, CQRS and Docker (Me...
PPT
Qbesv5 Peer Presentation
PDF
Airbnb - Braavos - Whered My Money Go
PPTX
Atl elevate programmatic developer slides
PDF
Building microservices with Scala, functional domain models and Spring Boot (...
PPTX
Detroit ELEVATE Track 2
PDF
AWS RoadShow Bristol - Part 2 Getting Started with AWS
PDF
AWS RoadShow Manchester Part 3 - Getting Started with AWS
PDF
AWS RoadShow Dublin - Part 3 Getting Started with AWS
PDF
AWS RoadShow Cambridge Part 4 - Getting Started with AWS
PDF
Beyond MVC: from Model to Domain
PPTX
Practical AngularJS
PPT
Intro to AppExchange - Building Composite Apps
DOC
Navjot_Resume_2017_Latest
PPTX
Agile methodologies based on BDD and CI by Nikolai Shevchenko
PPTX
ELEVATE Paris
PPTX
Developing Next-Gen Enterprise Web Application
PPTX
Eliminate the complexities of Event-Driven Architecture with Domain-Driven De...
PDF
Min-Maxing Software Costs - Laracon EU 2015
Week 8
Building and deploying microservices with event sourcing, CQRS and Docker (Me...
Qbesv5 Peer Presentation
Airbnb - Braavos - Whered My Money Go
Atl elevate programmatic developer slides
Building microservices with Scala, functional domain models and Spring Boot (...
Detroit ELEVATE Track 2
AWS RoadShow Bristol - Part 2 Getting Started with AWS
AWS RoadShow Manchester Part 3 - Getting Started with AWS
AWS RoadShow Dublin - Part 3 Getting Started with AWS
AWS RoadShow Cambridge Part 4 - Getting Started with AWS
Beyond MVC: from Model to Domain
Practical AngularJS
Intro to AppExchange - Building Composite Apps
Navjot_Resume_2017_Latest
Agile methodologies based on BDD and CI by Nikolai Shevchenko
ELEVATE Paris
Developing Next-Gen Enterprise Web Application
Eliminate the complexities of Event-Driven Architecture with Domain-Driven De...
Min-Maxing Software Costs - Laracon EU 2015
Ad

Recently uploaded (20)

PPTX
Big Data Technologies - Introduction.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPT
Teaching material agriculture food technology
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Machine Learning_overview_presentation.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Cloud computing and distributed systems.
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
Big Data Technologies - Introduction.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Teaching material agriculture food technology
Unlocking AI with Model Context Protocol (MCP)
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
MIND Revenue Release Quarter 2 2025 Press Release
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Spectral efficient network and resource selection model in 5G networks
MYSQL Presentation for SQL database connectivity
20250228 LYD VKU AI Blended-Learning.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Encapsulation_ Review paper, used for researhc scholars
Machine Learning_overview_presentation.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Programs and apps: productivity, graphics, security and other tools
Cloud computing and distributed systems.
A comparative analysis of optical character recognition models for extracting...
Advanced methodologies resolving dimensionality complications for autism neur...
Ad

Introduction to Domain driven design (LaravelBA #5)