SlideShare ist ein Scribd-Unternehmen logo
1 von 21
www.softserve.ua
Domain Driven
Design
Copyright © 2015 SoftServe, Inc.
www.softserve.ua
Agenda
1.Model
2.Ubiquitous language
3.Entity
4.Value Object
5.Service
1.Domain Service
2.Application Service
6.Aggregates
7.Factories
8.Repositories
9.Resources
www.softserve.ua
Model is a start for application
• The model is the backbone of a language used by all
team members.
• The model dictates the form of the design of the
heart of the software.
• The model is distilled knowledge.
www.softserve.ua
The Ubiquitous Language
• A language structured around the domain model and
used by all team members to connect all the
activities of the team with the software.
• Translation plus risk of misunderstanding is too high
of a cost
• Changes to the language, should cause a refactoring
to code
• Nouns == Classes
• Verbs == methods, services, etc.
www.softserve.ua
Entity
• An object defined primarily by its identity
• Is mutable, only entity's identifier is immutable
• Must validate itself and its children to enforce invariants
• Overriding equals() and hashcode() is required
• Entity values (other than the identity) can change over time,
but are only changed by the Entity's interface
• Can use Self-Encapsulation, create a validator class,
or have a validate method
• Must encapsulate business logic.
www.softserve.ua
Example
www.softserve.ua
Example
www.softserve.ua
Value Object
• Are defined by their attributes instead of their identity
• Should be immutable, so it only changes by replacement
• Don’t give it any identity.
• Are instantiated to represent elements of the design that we
care about only for what they are, not who they are
• Should use Self-Encapsulation. Have private setters that
validate properties, then call the setters from the constructor
to initialize.
www.softserve.ua
Examples
2. Driving route1. Pencil
www.softserve.ua
Examples
voyage identity
voyage required property
www.softserve.ua
An attribute should be
conceptually whole
www.softserve.ua
Service
• A SERVICE is an operation offered as an interface that stands
alone in the model, without encapsulating state as ENTITIES
and VALUE OBJECTS do.
• Only add business logic here if it doesn't "fit" inside an Entity
or Value Object.
• Don't mix CQRS methods.
• Domain services encapsulate domain concepts that just are
not naturally modeled as things.
• Application services constitute the application, or service,
layer.
www.softserve.ua
Example. Domain Service
www.softserve.ua
Example. Application Service
www.softserve.ua
Aggregates
• An AGGREGATE is a cluster of associated objects that we treat as a unit .
• The root is a single specific ENTITY contained in the AGGREGATE.
• The root ENTITY has global identity, and is ultimately responsible for
checking invariants.
• Nothing outside the AGGREGATE boundary can hold a reference to
anything inside, except to the root ENTITY.
• Only AGGREGATE roots can be obtained directly with database queries. All
other objects must be found by traversal of associations.
• When a change to any object within the AGGREGATE boundary is
committed, all invariants of the whole AGGREGATE must be satisfied.
www.softserve.ua
Example
www.softserve.ua
Factories
• Manages the creation of complex objects in the domain
• Requirements for a FACTORY are:
– Each creation method is atomic and enforces all invariants of
the created object or AGGREGATE.
– A FACTORY should only be able to produce an object in a
consistent state.
• For an ENTITY, this means the creation of the entire AGGREGATE,
with all the invariants satisfied, but probably with optional elements
still to be added.
• For an immutable VALUE OBJECT, this means that all attributes are
initialized to their correct final state.
www.softserve.ua
Example
www.softserve.ua
Repositories
• For each class/aggregate root setup a Repository for
in-memory access
• Provide add/remove methods for managing
persistent objects
• Manages the middle and end of an objects lifecycle
• Should never contain business logic
• Always produce fully initialized Entities, never
partial. Except in rare cases for performance
www.softserve.ua
Example
www.softserve.ua
Resources
Domain-Driven Design. Eric Evans
http://www-public.int-evry.fr/~gibson/Teaching/CSC7322/ReadingMaterial/Evans03.pdf
Domain Driven Design Quickly
http://www.infoq.com/minibooks/domain-driven-design-quickly
DDD Comunity
http://domaindrivendesign.org/
What is the difference between Entities and Value Objects?
http://culttt.com/2014/04/30/difference-entities-value-objects/
DDD sample
http://dddsample.sourceforge.net/
Service Layer. Martin Fowler
http://martinfowler.com/eaaCatalog/serviceLayer.html

Weitere ähnliche Inhalte

Ähnlich wie Domain Driven Design

Project_Goibibo information technology automation testing.pptx
Project_Goibibo information technology automation testing.pptxProject_Goibibo information technology automation testing.pptx
Project_Goibibo information technology automation testing.pptx
skhushi9980
 

Ähnlich wie Domain Driven Design (20)

Angular js 1.0-fundamentals
Angular js 1.0-fundamentalsAngular js 1.0-fundamentals
Angular js 1.0-fundamentals
 
Professionalizing the Front-end
Professionalizing the Front-endProfessionalizing the Front-end
Professionalizing the Front-end
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Building an Adaptive App in Ember
Building an Adaptive App in EmberBuilding an Adaptive App in Ember
Building an Adaptive App in Ember
 
adaptive_ember
adaptive_emberadaptive_ember
adaptive_ember
 
AngularJS
AngularJSAngularJS
AngularJS
 
Patterns and practices for building enterprise-scale HTML5 apps
Patterns and practices for building enterprise-scale HTML5 appsPatterns and practices for building enterprise-scale HTML5 apps
Patterns and practices for building enterprise-scale HTML5 apps
 
Weekly Meeting: Basic Design Pattern
Weekly Meeting: Basic Design PatternWeekly Meeting: Basic Design Pattern
Weekly Meeting: Basic Design Pattern
 
Better Page Object Handling with Loadable Component Pattern
Better Page Object Handling with Loadable Component PatternBetter Page Object Handling with Loadable Component Pattern
Better Page Object Handling with Loadable Component Pattern
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)
 
React a11y-csun
React a11y-csunReact a11y-csun
React a11y-csun
 
Implementing DDD Concepts in PHP
Implementing DDD Concepts in PHPImplementing DDD Concepts in PHP
Implementing DDD Concepts in PHP
 
Project_Goibibo information technology automation testing.pptx
Project_Goibibo information technology automation testing.pptxProject_Goibibo information technology automation testing.pptx
Project_Goibibo information technology automation testing.pptx
 
Introducing the Applitools Self Healing Execution Cloud.pdf
Introducing the Applitools Self Healing Execution Cloud.pdfIntroducing the Applitools Self Healing Execution Cloud.pdf
Introducing the Applitools Self Healing Execution Cloud.pdf
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
Ng Sydney Dynamic Templates Talk - 18 April 2018
Ng Sydney Dynamic Templates Talk - 18 April 2018Ng Sydney Dynamic Templates Talk - 18 April 2018
Ng Sydney Dynamic Templates Talk - 18 April 2018
 
Welcome to React.pptx
Welcome to React.pptxWelcome to React.pptx
Welcome to React.pptx
 
The Developers World
The Developers WorldThe Developers World
The Developers World
 
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friendWebcomponents are your frameworks best friend
Webcomponents are your frameworks best friend
 
Grails Services
Grails ServicesGrails Services
Grails Services
 

Kürzlich hochgeladen

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
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
VictorSzoltysek
 

Kürzlich hochgeladen (20)

A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
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 🔝✔️✔️
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
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
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
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...
 
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
 
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
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
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
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 

Domain Driven Design

  • 2. www.softserve.ua Agenda 1.Model 2.Ubiquitous language 3.Entity 4.Value Object 5.Service 1.Domain Service 2.Application Service 6.Aggregates 7.Factories 8.Repositories 9.Resources
  • 3. www.softserve.ua Model is a start for application • The model is the backbone of a language used by all team members. • The model dictates the form of the design of the heart of the software. • The model is distilled knowledge.
  • 4. www.softserve.ua The Ubiquitous Language • A language structured around the domain model and used by all team members to connect all the activities of the team with the software. • Translation plus risk of misunderstanding is too high of a cost • Changes to the language, should cause a refactoring to code • Nouns == Classes • Verbs == methods, services, etc.
  • 5. www.softserve.ua Entity • An object defined primarily by its identity • Is mutable, only entity's identifier is immutable • Must validate itself and its children to enforce invariants • Overriding equals() and hashcode() is required • Entity values (other than the identity) can change over time, but are only changed by the Entity's interface • Can use Self-Encapsulation, create a validator class, or have a validate method • Must encapsulate business logic.
  • 8. www.softserve.ua Value Object • Are defined by their attributes instead of their identity • Should be immutable, so it only changes by replacement • Don’t give it any identity. • Are instantiated to represent elements of the design that we care about only for what they are, not who they are • Should use Self-Encapsulation. Have private setters that validate properties, then call the setters from the constructor to initialize.
  • 11. www.softserve.ua An attribute should be conceptually whole
  • 12. www.softserve.ua Service • A SERVICE is an operation offered as an interface that stands alone in the model, without encapsulating state as ENTITIES and VALUE OBJECTS do. • Only add business logic here if it doesn't "fit" inside an Entity or Value Object. • Don't mix CQRS methods. • Domain services encapsulate domain concepts that just are not naturally modeled as things. • Application services constitute the application, or service, layer.
  • 15. www.softserve.ua Aggregates • An AGGREGATE is a cluster of associated objects that we treat as a unit . • The root is a single specific ENTITY contained in the AGGREGATE. • The root ENTITY has global identity, and is ultimately responsible for checking invariants. • Nothing outside the AGGREGATE boundary can hold a reference to anything inside, except to the root ENTITY. • Only AGGREGATE roots can be obtained directly with database queries. All other objects must be found by traversal of associations. • When a change to any object within the AGGREGATE boundary is committed, all invariants of the whole AGGREGATE must be satisfied.
  • 17. www.softserve.ua Factories • Manages the creation of complex objects in the domain • Requirements for a FACTORY are: – Each creation method is atomic and enforces all invariants of the created object or AGGREGATE. – A FACTORY should only be able to produce an object in a consistent state. • For an ENTITY, this means the creation of the entire AGGREGATE, with all the invariants satisfied, but probably with optional elements still to be added. • For an immutable VALUE OBJECT, this means that all attributes are initialized to their correct final state.
  • 19. www.softserve.ua Repositories • For each class/aggregate root setup a Repository for in-memory access • Provide add/remove methods for managing persistent objects • Manages the middle and end of an objects lifecycle • Should never contain business logic • Always produce fully initialized Entities, never partial. Except in rare cases for performance
  • 21. www.softserve.ua Resources Domain-Driven Design. Eric Evans http://www-public.int-evry.fr/~gibson/Teaching/CSC7322/ReadingMaterial/Evans03.pdf Domain Driven Design Quickly http://www.infoq.com/minibooks/domain-driven-design-quickly DDD Comunity http://domaindrivendesign.org/ What is the difference between Entities and Value Objects? http://culttt.com/2014/04/30/difference-entities-value-objects/ DDD sample http://dddsample.sourceforge.net/ Service Layer. Martin Fowler http://martinfowler.com/eaaCatalog/serviceLayer.html