SlideShare a Scribd company logo
Domain-Driven Design
          A Collaboration Between
  Domain Experts and Software Practitioners
The Book




           http://domaindrivendesign.org/books/evans_2003
Training




           http://www.domainlanguage.com/
do·main
dōˈmān n.
a sphere of knowledge,
influence, or activity




      "domain." Merriam-Webster.com. 2011. http://www.merriam-webster.com/dictionary/domain (17 October 2011).
Complexity is in the domain,
not the technology
Case Study: Election Reporting
Elections vs. Referendums
Elections and referendums are not as similar as
they at first appear

Election winners may be determined by plurality
and/or winning threshold

Referendums can only be passed by meeting a
winning threshold
Local vs. Statewide Elections
Town Meeting Day (March) elections are very different than
statewide elections (November)

During statewide elections, voters may be voting in both local and
statewide elections at the same time—each with different district
boundaries

District boundaries dictate reporting needs—statewide elections
need to be reported one way, local elections another
Districts
Some districts may contain only part of a municipality or ward

The Chittenden-3-6 Vermont Representative District contains all
of Winooski and part of Burlington’s Ward 1

Citizens in this part of Burlington’s Ward 1 vote in Winooski for
statewide elections and in Burlington for local elections

Audience expects both aggregate and detailed reporting

Redistricting can occur between elections
Let technology play
a supporting role
Models are tools used to
solve domain problems
Ames Room
Used in The Lord Of The
Rings: The Fellowship of
the Ring to make the
hobbits appear the
correct size in relation
to Gandalf

We are always using
mental models to
understand the world
around us—we do not
perceive an objective
reality


                           By Alex Valavanis (own work) [public domain], via Wikimedia Commons
"Why I prefer Fahrenheit to Celsius [Fixed]." reddit. 2012.
http://www.reddit.com/r/funny/comments/wigk1/why_i_prefer_fahrenheit_to_celsius_fixed/ (16 September 2012).
Collaboratively explore the model
with both domain experts and
software practitioners
Case Study:
Three-Dimensional Animation
Software Practioner:
Edwin Catmull
Studied physics and computer science

Made many notable computer graphics discoveries

Eventually moved from two-dimensional to
three-dimensional animation

Hired by Lucasfilm to bring his expertise to the
entertainment field
Domain Expert:
John Lasseter
Studied animation and taught by veteran animators from Disney

Realized early-on the potential for computer generated imagery

Worked at, but eventually fired from, Disney

Hired by Edwin Catmull at Lucasfilm as an “Interface Designer”
because Catmull’s job didn’t include hiring animators[1]




          1. Buckley, A. M. "Chapter 3: Art Meets Science." Pixar: The Company and Its Founders. Edina, MN: ABDO, 2011. 27. Print.
“Throughout the process, Lasseter
worked side-by-side with the computer
scientists. Lasseter’s requests pushed
them to develop new tools, and their
feedback helped him learn the digital
animation process.”[1]



    1. Buckley, A. M. "Chapter 3: Art Meets Science." Pixar: The Company and Its Founders. Edina, MN: ABDO, 2011. 30. Print.
Identify your core domain
Core Domain
Identify your core domain

Distill your core domain

Focus your resources on the core domain
Collaboratively explore
domain models
The Model
A model is an abstract set of tools that is used to
solve problems within a domain

While represented in code, do not think of the
model as just code

A “real world model” is a fool’s errand

The model must be explored collaboratively with
domain experts and software practitioners
“The map is not the territory.”
—Alfred Korzybski
Magritte, René. The Treachery of Images (La trahision des images). 1929. Oil on canvas. Los Angeles County Museum of Art, Los Angeles, California.
This is not a pipe.


Magritte, René. The Treachery of Images (La trahision des images). 1929. Oil on canvas. Los Angeles County Museum of Art, Los Angeles, California.
"Everything simple is false. Everything
which is complex is unusable."
—Paul Valéry
There are always multiple models
Bounded Context
Delineates the applicability of a particular model

Bounded contexts allow each model to be explored in isolation

Clearly define:
  • Who is responsible for each bounded context
  • To which parts of the application is the bounded
    context applicable
  • What manifestations the bounded context will take
    (code, database schemas, etc.)

Document the interactions between bounded contexts
with a context map
Ubiquitous Language
Speak a ubiquitous language within a bounded context

Terms must be clearly defined, unambiguous, and consistent

Critically important when communicating between
domain experts and software practitioners

The ubiquitous language will (and must) evolve as a progressively
richer understanding of the domain and the model are achieved

If the ubiquitous language cannot be used to clearly express
complex ideas, then you have more work to do!
Exploring the Model
A Model Exploration Process
Ask a domain expert to tell you a story (the scenario)

Propose a model

Code the scenario using unit tests

Repeat
Use concrete scenarios in discussions
with domain experts and in unit tests
Building Blocks
Entity
Defined by a thread of continuity and identity

Only responsibilities should be around identity and life cycle

May be composed of other entities and/or value objects
Value Object
Defined by its encapsulated attributes

Treat value objects as immutable

Delegate business logic to value objects
Defining an object as an entity or a
value object is context-dependent
Aggregate
A group of related entities and value objects

Useful when defining transaction, distribution
and concurrency boundaries

A model will likely have multiple aggregates
Aggregate Root
Designate one entity as the aggregate root

Allow external references to only the aggregate root

Use unidirectional references within an aggregate root
for less complexity
  • Example: Reference a line item’s order, or an order’s line items,
     but not both

Maintain references on the “many” side of a “one-to-many”
relationships for less complexity:
  • Example: Reference a line item’s order, rather than an order’s
    line items
Repository
Delegate persistence of an aggregate root to a repository

A repository should behave as if it were an in-memory data store

If using an object-relational mapper (ORM):
Database -> ORM -> Repository

Use an in-memory strategy for unit tests

Straddles persistence and domain layers, allowing you to
stay focused on the domain model
Service
A place for operations that aren’t naturally part of
any domain object

Like value objects, services should be immutable

Operations on services are stateless
Command-Query Responsibility
Segregation (CQRS)
Commands & Queries
Commands are responsible for changing state

Queries are responsible for retrieving state

A commands may delegate the actual state change
to a domain event
Write Model/Read Model
Define one model for writing data (commands)

Define another model for reading data (queries)

Both models will likely share aggregate root entity identifiers
Event Sourcing[1]




                    1. http://martinfowler.com/eaaDev/EventSourcing.html
Domain Event
Something important that happens within the domain
that may lead to a state change in a domain object

Domain events can trigger other domain events (e.g.
three strikes triggers an out)

Domain events are immutable

Typically stored in an event log
Event Log
Current state can be computed by reading the event log

Retroactive events can be used to “fix” application state

Current state may be cached, if necessary for performance

Can also serve as an audit log
Supple Design
Closure of Operations
Have a method on a value object that returns an instance
of the same type of value object

Any method arguments should also be the same type as
the value object

Example: 2 + 3 = 5
  • “2” is a value object of type integer
  • integer has an add method
  • add method accepts an argument of type integer
  • add method returns an integer
  • integers are closed under the operation of addition
Other Techniques
Intention-revealing interfaces

Side-effect free functions

Assertions
Strategic Design
Context Map
Draw a context map of the current bounded contexts

Map what actually exists—not what you wish existed!

Identify relationships between contexts
Relationship Patterns
                   customer/            anticorruption
  partnership       supplier                 layer




shared kernel   big ball of         separate ways
                   mud




    open host          conformist           published
     service                                language
Distillation
Types of Domains
A model my represent:
  • your core domain
  • a supporting domain
  • a generic subdomain
Focus your modeling efforts on the core domain

Consider outsourcing work on supporting domains

Consider off-the-shelf software for generic subdomains
Identifying the Core Domain
Ask organizational leaders and domain experts:
  • What keeps you awake at night?
  • What makes your system worth writing?
  • Why not buy it off the shelf?
  • Why not outsource it?
Don’t settle on not having
access to a domain expert!
http://oreilly.com/catalog/9781449303129/   http://oreilly.com/catalog/9781449303433/
Thank You
                                   @BradleyHolt
                              http://bradley-holt.com




Copyright © 2011-2012 Bradley Holt. All rights reserved.

More Related Content

Similar to Domain-Driven Design

Domain-Driven Design at ZendCon 2012
Domain-Driven Design at ZendCon 2012Domain-Driven Design at ZendCon 2012
Domain-Driven Design at ZendCon 2012
Bradley Holt
 
Domain Driven Design Quickly
Domain Driven Design QuicklyDomain Driven Design Quickly
Domain Driven Design Quickly
Mariam Hakobyan
 
ZendCon 2011 UnCon Domain-Driven Design
ZendCon 2011 UnCon Domain-Driven DesignZendCon 2011 UnCon Domain-Driven Design
ZendCon 2011 UnCon Domain-Driven Design
Bradley Holt
 
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
Dmitry Geyzersky
 
Up to speed in domain driven design
Up to speed in domain driven designUp to speed in domain driven design
Up to speed in domain driven design
Rick van der Arend
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
Muhammad Ali
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)
Tom Kocjan
 
Domain Driven Design Big Picture Strategic Patterns
Domain Driven Design Big Picture Strategic PatternsDomain Driven Design Big Picture Strategic Patterns
Domain Driven Design Big Picture Strategic Patterns
Mark Windholtz
 
Oops design pattern_amitgupta
Oops design pattern_amitguptaOops design pattern_amitgupta
Oops design pattern_amitgupta
Amit Gupta, MCSD TOGAF
 
Domain Driven Design in the Browser - Cameron Edwards
Domain Driven Design in the Browser - Cameron EdwardsDomain Driven Design in the Browser - Cameron Edwards
Domain Driven Design in the Browser - Cameron Edwards
Hakka Labs
 
Design Patterns.ppt
Design Patterns.pptDesign Patterns.ppt
Design Patterns.ppt
TanishaKochak
 
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
thinkddd
 
Online TechTalk  "Patterns in Embedded SW Design"
Online TechTalk  "Patterns in Embedded SW Design"Online TechTalk  "Patterns in Embedded SW Design"
Online TechTalk  "Patterns in Embedded SW Design"
GlobalLogic Ukraine
 
Brownfield Domain Driven Design
Brownfield Domain Driven DesignBrownfield Domain Driven Design
Brownfield Domain Driven Design
Nicolò Pignatelli
 
Introduction to object oriented programming
Introduction to object oriented programmingIntroduction to object oriented programming
Introduction to object oriented programmingAbzetdin Adamov
 
Excavating the knowledge of our ancestors
Excavating the knowledge of our ancestorsExcavating the knowledge of our ancestors
Excavating the knowledge of our ancestors
Uwe Friedrichsen
 
History of Object Orientation in OOP.ppt
History of Object Orientation in OOP.pptHistory of Object Orientation in OOP.ppt
History of Object Orientation in OOP.ppt
athar549116
 
History of Object Orientation in OOP.ppt
History of Object Orientation in OOP.pptHistory of Object Orientation in OOP.ppt
History of Object Orientation in OOP.ppt
Muhammad Athar
 
Refreshing Domain Driven Design
Refreshing Domain Driven DesignRefreshing Domain Driven Design
Refreshing Domain Driven Design
André Borgonovo
 
D4U presentation 2 - coherency and consistency in domain models
D4U   presentation 2 - coherency and consistency in domain modelsD4U   presentation 2 - coherency and consistency in domain models
D4U presentation 2 - coherency and consistency in domain models
Paul Valckenaers
 

Similar to Domain-Driven Design (20)

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 Quickly
Domain Driven Design QuicklyDomain Driven Design Quickly
Domain Driven Design Quickly
 
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 and model driven development
Domain driven design and model driven developmentDomain driven design and model driven development
Domain driven design and model driven development
 
Up to speed in domain driven design
Up to speed in domain driven designUp to speed in domain driven design
Up to speed in domain driven design
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)
 
Domain Driven Design Big Picture Strategic Patterns
Domain Driven Design Big Picture Strategic PatternsDomain Driven Design Big Picture Strategic Patterns
Domain Driven Design Big Picture Strategic Patterns
 
Oops design pattern_amitgupta
Oops design pattern_amitguptaOops design pattern_amitgupta
Oops design pattern_amitgupta
 
Domain Driven Design in the Browser - Cameron Edwards
Domain Driven Design in the Browser - Cameron EdwardsDomain Driven Design in the Browser - Cameron Edwards
Domain Driven Design in the Browser - Cameron Edwards
 
Design Patterns.ppt
Design Patterns.pptDesign Patterns.ppt
Design Patterns.ppt
 
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
 
Online TechTalk  "Patterns in Embedded SW Design"
Online TechTalk  "Patterns in Embedded SW Design"Online TechTalk  "Patterns in Embedded SW Design"
Online TechTalk  "Patterns in Embedded SW Design"
 
Brownfield Domain Driven Design
Brownfield Domain Driven DesignBrownfield Domain Driven Design
Brownfield Domain Driven Design
 
Introduction to object oriented programming
Introduction to object oriented programmingIntroduction to object oriented programming
Introduction to object oriented programming
 
Excavating the knowledge of our ancestors
Excavating the knowledge of our ancestorsExcavating the knowledge of our ancestors
Excavating the knowledge of our ancestors
 
History of Object Orientation in OOP.ppt
History of Object Orientation in OOP.pptHistory of Object Orientation in OOP.ppt
History of Object Orientation in OOP.ppt
 
History of Object Orientation in OOP.ppt
History of Object Orientation in OOP.pptHistory of Object Orientation in OOP.ppt
History of Object Orientation in OOP.ppt
 
Refreshing Domain Driven Design
Refreshing Domain Driven DesignRefreshing Domain Driven Design
Refreshing Domain Driven Design
 
D4U presentation 2 - coherency and consistency in domain models
D4U   presentation 2 - coherency and consistency in domain modelsD4U   presentation 2 - coherency and consistency in domain models
D4U presentation 2 - coherency and consistency in domain models
 

More from Bradley Holt

Entity Relationships in a Document Database at CouchConf Boston
Entity Relationships in a Document Database at CouchConf BostonEntity Relationships in a Document Database at CouchConf Boston
Entity Relationships in a Document Database at CouchConf Boston
Bradley Holt
 
CouchConf NYC CouchApps
CouchConf NYC CouchAppsCouchConf NYC CouchApps
CouchConf NYC CouchApps
Bradley Holt
 
ZendCon 2011 Learning CouchDB
ZendCon 2011 Learning CouchDBZendCon 2011 Learning CouchDB
ZendCon 2011 Learning CouchDB
Bradley Holt
 
jQuery Conference Boston 2011 CouchApps
jQuery Conference Boston 2011 CouchAppsjQuery Conference Boston 2011 CouchApps
jQuery Conference Boston 2011 CouchApps
Bradley Holt
 
OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchApps
Bradley Holt
 
OSCON 2011 Learning CouchDB
OSCON 2011 Learning CouchDBOSCON 2011 Learning CouchDB
OSCON 2011 Learning CouchDB
Bradley Holt
 
Load Balancing with Apache
Load Balancing with ApacheLoad Balancing with Apache
Load Balancing with Apache
Bradley Holt
 
CouchDB at New York PHP
CouchDB at New York PHPCouchDB at New York PHP
CouchDB at New York PHP
Bradley Holt
 
Intermediate PHP
Intermediate PHPIntermediate PHP
Intermediate PHP
Bradley Holt
 
New Features in PHP 5.3
New Features in PHP 5.3New Features in PHP 5.3
New Features in PHP 5.3
Bradley Holt
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Bradley Holt
 
Resource-Oriented Web Services
Resource-Oriented Web ServicesResource-Oriented Web Services
Resource-Oriented Web Services
Bradley Holt
 
Zend Framework Quick Start Walkthrough
Zend Framework Quick Start WalkthroughZend Framework Quick Start Walkthrough
Zend Framework Quick Start Walkthrough
Bradley Holt
 
Burlington, VT PHP Users Group Subversion Presentation
Burlington, VT PHP Users Group Subversion PresentationBurlington, VT PHP Users Group Subversion Presentation
Burlington, VT PHP Users Group Subversion Presentation
Bradley Holt
 

More from Bradley Holt (14)

Entity Relationships in a Document Database at CouchConf Boston
Entity Relationships in a Document Database at CouchConf BostonEntity Relationships in a Document Database at CouchConf Boston
Entity Relationships in a Document Database at CouchConf Boston
 
CouchConf NYC CouchApps
CouchConf NYC CouchAppsCouchConf NYC CouchApps
CouchConf NYC CouchApps
 
ZendCon 2011 Learning CouchDB
ZendCon 2011 Learning CouchDBZendCon 2011 Learning CouchDB
ZendCon 2011 Learning CouchDB
 
jQuery Conference Boston 2011 CouchApps
jQuery Conference Boston 2011 CouchAppsjQuery Conference Boston 2011 CouchApps
jQuery Conference Boston 2011 CouchApps
 
OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchApps
 
OSCON 2011 Learning CouchDB
OSCON 2011 Learning CouchDBOSCON 2011 Learning CouchDB
OSCON 2011 Learning CouchDB
 
Load Balancing with Apache
Load Balancing with ApacheLoad Balancing with Apache
Load Balancing with Apache
 
CouchDB at New York PHP
CouchDB at New York PHPCouchDB at New York PHP
CouchDB at New York PHP
 
Intermediate PHP
Intermediate PHPIntermediate PHP
Intermediate PHP
 
New Features in PHP 5.3
New Features in PHP 5.3New Features in PHP 5.3
New Features in PHP 5.3
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Resource-Oriented Web Services
Resource-Oriented Web ServicesResource-Oriented Web Services
Resource-Oriented Web Services
 
Zend Framework Quick Start Walkthrough
Zend Framework Quick Start WalkthroughZend Framework Quick Start Walkthrough
Zend Framework Quick Start Walkthrough
 
Burlington, VT PHP Users Group Subversion Presentation
Burlington, VT PHP Users Group Subversion PresentationBurlington, VT PHP Users Group Subversion Presentation
Burlington, VT PHP Users Group Subversion Presentation
 

Recently uploaded

GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 

Recently uploaded (20)

GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 

Domain-Driven Design

  • 1. Domain-Driven Design A Collaboration Between Domain Experts and Software Practitioners
  • 2. The Book http://domaindrivendesign.org/books/evans_2003
  • 3. Training http://www.domainlanguage.com/
  • 4. do·main dōˈmān n. a sphere of knowledge, influence, or activity "domain." Merriam-Webster.com. 2011. http://www.merriam-webster.com/dictionary/domain (17 October 2011).
  • 5. Complexity is in the domain, not the technology
  • 7. Elections vs. Referendums Elections and referendums are not as similar as they at first appear Election winners may be determined by plurality and/or winning threshold Referendums can only be passed by meeting a winning threshold
  • 8. Local vs. Statewide Elections Town Meeting Day (March) elections are very different than statewide elections (November) During statewide elections, voters may be voting in both local and statewide elections at the same time—each with different district boundaries District boundaries dictate reporting needs—statewide elections need to be reported one way, local elections another
  • 9. Districts Some districts may contain only part of a municipality or ward The Chittenden-3-6 Vermont Representative District contains all of Winooski and part of Burlington’s Ward 1 Citizens in this part of Burlington’s Ward 1 vote in Winooski for statewide elections and in Burlington for local elections Audience expects both aggregate and detailed reporting Redistricting can occur between elections
  • 10. Let technology play a supporting role
  • 11. Models are tools used to solve domain problems
  • 12. Ames Room Used in The Lord Of The Rings: The Fellowship of the Ring to make the hobbits appear the correct size in relation to Gandalf We are always using mental models to understand the world around us—we do not perceive an objective reality By Alex Valavanis (own work) [public domain], via Wikimedia Commons
  • 13. "Why I prefer Fahrenheit to Celsius [Fixed]." reddit. 2012. http://www.reddit.com/r/funny/comments/wigk1/why_i_prefer_fahrenheit_to_celsius_fixed/ (16 September 2012).
  • 14. Collaboratively explore the model with both domain experts and software practitioners
  • 16. Software Practioner: Edwin Catmull Studied physics and computer science Made many notable computer graphics discoveries Eventually moved from two-dimensional to three-dimensional animation Hired by Lucasfilm to bring his expertise to the entertainment field
  • 17. Domain Expert: John Lasseter Studied animation and taught by veteran animators from Disney Realized early-on the potential for computer generated imagery Worked at, but eventually fired from, Disney Hired by Edwin Catmull at Lucasfilm as an “Interface Designer” because Catmull’s job didn’t include hiring animators[1] 1. Buckley, A. M. "Chapter 3: Art Meets Science." Pixar: The Company and Its Founders. Edina, MN: ABDO, 2011. 27. Print.
  • 18. “Throughout the process, Lasseter worked side-by-side with the computer scientists. Lasseter’s requests pushed them to develop new tools, and their feedback helped him learn the digital animation process.”[1] 1. Buckley, A. M. "Chapter 3: Art Meets Science." Pixar: The Company and Its Founders. Edina, MN: ABDO, 2011. 30. Print.
  • 20. Core Domain Identify your core domain Distill your core domain Focus your resources on the core domain
  • 22. The Model A model is an abstract set of tools that is used to solve problems within a domain While represented in code, do not think of the model as just code A “real world model” is a fool’s errand The model must be explored collaboratively with domain experts and software practitioners
  • 23. “The map is not the territory.” —Alfred Korzybski
  • 24. Magritte, René. The Treachery of Images (La trahision des images). 1929. Oil on canvas. Los Angeles County Museum of Art, Los Angeles, California.
  • 25. This is not a pipe. Magritte, René. The Treachery of Images (La trahision des images). 1929. Oil on canvas. Los Angeles County Museum of Art, Los Angeles, California.
  • 26.
  • 27. "Everything simple is false. Everything which is complex is unusable." —Paul Valéry
  • 28. There are always multiple models
  • 29. Bounded Context Delineates the applicability of a particular model Bounded contexts allow each model to be explored in isolation Clearly define: • Who is responsible for each bounded context • To which parts of the application is the bounded context applicable • What manifestations the bounded context will take (code, database schemas, etc.) Document the interactions between bounded contexts with a context map
  • 30. Ubiquitous Language Speak a ubiquitous language within a bounded context Terms must be clearly defined, unambiguous, and consistent Critically important when communicating between domain experts and software practitioners The ubiquitous language will (and must) evolve as a progressively richer understanding of the domain and the model are achieved If the ubiquitous language cannot be used to clearly express complex ideas, then you have more work to do!
  • 32. A Model Exploration Process Ask a domain expert to tell you a story (the scenario) Propose a model Code the scenario using unit tests Repeat
  • 33.
  • 34. Use concrete scenarios in discussions with domain experts and in unit tests
  • 36. Entity Defined by a thread of continuity and identity Only responsibilities should be around identity and life cycle May be composed of other entities and/or value objects
  • 37. Value Object Defined by its encapsulated attributes Treat value objects as immutable Delegate business logic to value objects
  • 38. Defining an object as an entity or a value object is context-dependent
  • 39. Aggregate A group of related entities and value objects Useful when defining transaction, distribution and concurrency boundaries A model will likely have multiple aggregates
  • 40. Aggregate Root Designate one entity as the aggregate root Allow external references to only the aggregate root Use unidirectional references within an aggregate root for less complexity • Example: Reference a line item’s order, or an order’s line items, but not both Maintain references on the “many” side of a “one-to-many” relationships for less complexity: • Example: Reference a line item’s order, rather than an order’s line items
  • 41. Repository Delegate persistence of an aggregate root to a repository A repository should behave as if it were an in-memory data store If using an object-relational mapper (ORM): Database -> ORM -> Repository Use an in-memory strategy for unit tests Straddles persistence and domain layers, allowing you to stay focused on the domain model
  • 42. Service A place for operations that aren’t naturally part of any domain object Like value objects, services should be immutable Operations on services are stateless
  • 44. Commands & Queries Commands are responsible for changing state Queries are responsible for retrieving state A commands may delegate the actual state change to a domain event
  • 45. Write Model/Read Model Define one model for writing data (commands) Define another model for reading data (queries) Both models will likely share aggregate root entity identifiers
  • 46. Event Sourcing[1] 1. http://martinfowler.com/eaaDev/EventSourcing.html
  • 47. Domain Event Something important that happens within the domain that may lead to a state change in a domain object Domain events can trigger other domain events (e.g. three strikes triggers an out) Domain events are immutable Typically stored in an event log
  • 48. Event Log Current state can be computed by reading the event log Retroactive events can be used to “fix” application state Current state may be cached, if necessary for performance Can also serve as an audit log
  • 50. Closure of Operations Have a method on a value object that returns an instance of the same type of value object Any method arguments should also be the same type as the value object Example: 2 + 3 = 5 • “2” is a value object of type integer • integer has an add method • add method accepts an argument of type integer • add method returns an integer • integers are closed under the operation of addition
  • 53. Context Map Draw a context map of the current bounded contexts Map what actually exists—not what you wish existed! Identify relationships between contexts
  • 54. Relationship Patterns customer/ anticorruption partnership supplier layer shared kernel big ball of separate ways mud open host conformist published service language
  • 56. Types of Domains A model my represent: • your core domain • a supporting domain • a generic subdomain Focus your modeling efforts on the core domain Consider outsourcing work on supporting domains Consider off-the-shelf software for generic subdomains
  • 57. Identifying the Core Domain Ask organizational leaders and domain experts: • What keeps you awake at night? • What makes your system worth writing? • Why not buy it off the shelf? • Why not outsource it?
  • 58. Don’t settle on not having access to a domain expert!
  • 59. http://oreilly.com/catalog/9781449303129/ http://oreilly.com/catalog/9781449303433/
  • 60. Thank You @BradleyHolt http://bradley-holt.com Copyright © 2011-2012 Bradley Holt. All rights reserved.

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. Is a telephone number an entity or a value object? In a CRM, it’s probably a value object. In a telephone company, a phone number may be an entity.\n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. Dates are another example of where closure of operations could be useful\n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n