SlideShare uma empresa Scribd logo
1 de 35
Domain Driven Design
Analysis and Design
Jeppe Cramon - @jeppec
Cloud Create ApS
@jeppec
"I consider 'getting the boundaries
right' the single design decision
with the most significant impact
over the entire life of a software
project."
@ziobrando
@jeppec 3
@jeppec
This highly depends on
• How likely are things to change
• And what parts that change together
Classic domain analysis
@jeppec
Result is often fragmented domain logic
Focus on Nouns (Entities)
and retrofit Verbs later
@jeppec
Customer
CustomerId
FirstName
LastName
Email
…
Order
OrderId
Total
DeliveryAddress
Status
…
OrderLine
Quantity
Product
ProductId
Name
Images
Price
Others have bought
@jeppec
If we primarily model around nouns/entities
we can easily violate the
Single Responsibility Principle
Where a change to requirements
is likely to require changes
to multiple entity classes
@jeppec
Business introduces new rule
Product price depends on Customer Status
@jeppec
Customer
CustomerId
FirstName
LastName
Email
Status
…
Order
OrderId
Total
DeliveryAddress
Status
…
OrderLine
Quantity
Product
ProductId
Name
Description
Images
Price
Others have bought
What
now?
@jeppec
Jim Coplien
@jeppec
Most applications are built with CRUD as
the main paradigm
Intention gets lost
@jeppec
We need to shift focus from pure data
towards intent and process automation
This means a change from CRUD style application design,
where the process was implicit and stored in the minds of
the users
First I need to
enter the
employee in
this screen
Then I need to
press a button in
the user system
so they’re
properly created
And the I need
to add their
access card to
this screen and
press Activate
@jeppec
Task-based/Inductive UI
• Traditional CRUD UI is what I would call a WHAT UI
• Task based UI’s focuses on HOW the user wants to
use the application
• Guides users through the work process
• The UI becomes an intrinsic part of the design
• The UI design directly affects our commands and
thereby our transactional boundaries
@jeppec
We need to capture User Intent at the UI
CRUD style
Task based style
Intent
@jeppec
Capturing intent in the form of a Command
A Command is prescriptive of what should happen, and its primary goal is to
capture USER INTENT
A Command
supports a single usecase and
targets a single business object
within a single Transaction
Commands always carry a name in its imperative form:
• AcceptOrder
• ShipOrder
• CancelOrder
• ReimburseCustomer
• Etc.
“A command describes a Task that you want someone
else to carry out for you and where the recipient can
choose to reject the Command”
@jeppec
Example
public class OrderService {
public void handle(AcceptOrder cmd) {
orderRepository.add(new Order(cmd.orderId,
cmd.orderLines));
…
}
@jeppec
instead of focusing on Nouns!
@jeppec
When discussing use cases with Business Experts
@jeppec
and what fields that are separate
@jeppec
@jeppec
Customer
CustomerId
FirstName
LastName
Email
Status
…
Product
ProductId
Name
Description
Images
Price
Decomposing the domain
Customer
FirstName
LastName
Customer
Status
Product
Price
Product
Name
Description
@jeppec
But don’t name the piles before you know what they are
This avoids cognitive bias!
@jeppec
Give the piles made up names, such as
colors
@jeppec
What are the these problem domain piles?
@jeppec
Business Capability alignment
“The advantage of business capabilities is their
remarkable level of stability. If we take a typical
insurance organisation, it will likely have sales,
marketing, policy administration, claims
management, risk assessment, billing, payments,
customer service, human resource management, rate
management, document management, channel
management, commissions management,
compliance, IT support and human task management
capabilities. In fact, any insurance organisation will
very likely have many of these capabilities.”
See http://bill-poole.blogspot.dk/2008/07/business-
capabilities.html
@jeppec
Business – IT alignment
• We want the Business and IT to speak the same Ubiquitous
language
• Want want our architecture to be aligned with the
business capabilities
• Because these capabilities are stable
@jeppec
Many perspectives on data
Online Retail System
Product
Unit Price
Promotional Price
Promotion End Date
Stock Keeping Unit (SKU)
Quantity On Hand (QOH)
Location Code
Price
Quantity Ordered
Name
The lifecycle of the data is VERY important!
Customer
Pricing
Inventory
Sales
Management Reporting
@jeppec
Smaller models & clear data ownership
Retail System
Pricing
Product
ProductID
Unit Price
Promotional
Price
…
Pricing
Inventory
Product
ProductID
SKU
QOH
Location Code
…
Inventory
Sales
Product
ProductID
Name
Description
Quantity
Ordered
…
Sales
Shared Entity identity
DDD:
Bounded
Context
Business
Capability
DDD:
Aggregate
@jeppec
Aggregates
Invoice
InvoiceLine
*
Account *
What:
• Cluster coherent Entities and Value
Objects, with complex associations into
Aggregates with well defined boundaries.
• Choose one entity to be root and control
access to objects inside the boundary
through the root.
Motivation:
Control invariants and consistency through the aggregate root.
Ensuring consistency & transactional boundaries for Distributed scenarios!
Root
*
*
@jeppec
Entities
Motivators:
Objects are defined by identity and NOT by their
attributes.
May have lifecycle, can change form by time and
context (A Person that becomes a father, who becomes
a grand father, etc.)
Focus is on Who and not on what!
Customer
- ID/Social Security Number : Number
@jeppec
Value Objects
Customer
- ID/Social Security Number : Number
Address
- street : String
- zipCode : String
1
Motivators:
Objects which Measures,
Quantifies or Describes a thing in
the domain. They’re immutable
and defined by their attributes
(not by their identity) and doesn’t
have a lifecycle.
Focus is on What and not on who!
@jeppec
Aggregates refer to each other
by ID
they NEVER use memory pointers, join tables or
remote calls
@jeppec
Bounded Contexts and Aggregates
Sales
Product
Customer
customerId
…
Order
orderId
customerId
…
OrderLine
orderId
productId
quantity
timestamp
priceId
ProductCategory
productCategoryId
…
Pricing
Product
productId
productCategoryId
name
tag
...
Product-Price
priceId
productId
normalPrice
discountPeriods
…
@jeppec
For more
see
Blog: https://cramonblog.wordpress.com/
Homepage: http://cloudcreate.dk/
Twitter: @jeppec

Mais conteúdo relacionado

Mais procurados

SOA Pattern Event Driven Messaging
SOA Pattern Event Driven MessagingSOA Pattern Event Driven Messaging
SOA Pattern Event Driven Messaging
WSO2
 

Mais procurados (16)

REST != WebAPI
REST != WebAPIREST != WebAPI
REST != WebAPI
 
Designing DDD Aggregates
Designing DDD AggregatesDesigning DDD Aggregates
Designing DDD Aggregates
 
Implementing DDD with C#
Implementing DDD with C#Implementing DDD with C#
Implementing DDD with C#
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
DDD Basics - Context mapping
DDD Basics - Context mappingDDD Basics - Context mapping
DDD Basics - Context mapping
 
Effective Akka v2.0 - Jamie Allen
Effective Akka v2.0 - Jamie AllenEffective Akka v2.0 - Jamie Allen
Effective Akka v2.0 - Jamie Allen
 
SOA Pattern Event Driven Messaging
SOA Pattern Event Driven MessagingSOA Pattern Event Driven Messaging
SOA Pattern Event Driven Messaging
 
The "Why", "What" and "How" of Microservices
The "Why", "What" and "How" of Microservices The "Why", "What" and "How" of Microservices
The "Why", "What" and "How" of Microservices
 
Application Architecture
Application ArchitectureApplication Architecture
Application Architecture
 
DDD and Microservices: Like Peanut Butter and Jelly - Matt Stine
DDD and Microservices: Like Peanut Butter and Jelly - Matt StineDDD and Microservices: Like Peanut Butter and Jelly - Matt Stine
DDD and Microservices: Like Peanut Butter and Jelly - Matt Stine
 
Introduction to-ddd
Introduction to-dddIntroduction to-ddd
Introduction to-ddd
 
SOA vs EDA
SOA vs EDASOA vs EDA
SOA vs EDA
 
CQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architectureCQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architecture
 
Event sourcing
Event sourcingEvent sourcing
Event sourcing
 
Domain driven design
Domain driven designDomain driven design
Domain driven design
 
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
 

Semelhante a Domain Driven Analysis and Design

Semelhante a Domain Driven Analysis and Design (20)

How Custom is your Org? CEER at Dreamforce 2019
How Custom is your Org?  CEER at Dreamforce 2019How Custom is your Org?  CEER at Dreamforce 2019
How Custom is your Org? CEER at Dreamforce 2019
 
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
 
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
 
Designing salesforce solutions for reuse - Josh Dennis
Designing salesforce solutions for reuse - Josh DennisDesigning salesforce solutions for reuse - Josh Dennis
Designing salesforce solutions for reuse - Josh Dennis
 
Bring stories to life using BDD (Behaviour driven development)
Bring stories to life using BDD (Behaviour driven development)Bring stories to life using BDD (Behaviour driven development)
Bring stories to life using BDD (Behaviour driven development)
 
Code & Cannoli - Domain Driven Design
Code & Cannoli - Domain Driven DesignCode & Cannoli - Domain Driven Design
Code & Cannoli - 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
 
Learning to run
Learning to runLearning to run
Learning to run
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven Design
 
Agile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAgile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven Design
 
A Case for Outside-In Design
A Case for Outside-In DesignA Case for Outside-In Design
A Case for Outside-In Design
 
Introduction To Msbi By Yasir
Introduction To Msbi By YasirIntroduction To Msbi By Yasir
Introduction To Msbi By Yasir
 
Updated: Should you be using an Event Driven Architecture
Updated: Should you be using an Event Driven ArchitectureUpdated: Should you be using an Event Driven Architecture
Updated: Should you be using an Event Driven Architecture
 
黑豹 ch4 ddd pattern practice (2)
黑豹 ch4 ddd pattern practice (2)黑豹 ch4 ddd pattern practice (2)
黑豹 ch4 ddd pattern practice (2)
 
Testing an onion architecture - done right
Testing an onion architecture - done rightTesting an onion architecture - done right
Testing an onion architecture - done right
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
 
Business Event Driven Architecture & Governance in Action
Business Event Driven Architecture & Governance in ActionBusiness Event Driven Architecture & Governance in Action
Business Event Driven Architecture & Governance in Action
 
Project scope preparation
Project scope preparationProject scope preparation
Project scope preparation
 
Autonomous microservices for a Financial System
Autonomous microservices for a Financial SystemAutonomous microservices for a Financial System
Autonomous microservices for a Financial System
 
Composing User Stories - Beginners Guide
Composing User Stories - Beginners GuideComposing User Stories - Beginners Guide
Composing User Stories - Beginners Guide
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 

Domain Driven Analysis and Design