SlideShare a Scribd company logo
DOMAIN DRIVEN
DESIGN
Prepared for the 4th Software Engineering Colloquium
Lorraine Steyn and Paul Johnson
Domain Driven Design                        2




Home Truths
A design should be as simple as possible,
      but no simpler



Agile development is about collaboration
      and communication
Domain Driven Design                                         3




Agile, briefly
Agile practitioners can be design avoidant!
      Avoid documentation, no big upfront analysis


Scrum and Agile encourage rapid change
      Quicker route to the BOM
      No time for design?
      Small user stories lose the big picture
      Scrum is particularly Process focused, and does not
       prescribe the technical approach
Domain Driven Design                                          4




Agile – the good bits
Short iterations
      Deliver working software in 2 to 3 week “sprints”
Empower people
      Team ownership
      Team commitment to deliver
Structured Process through Scrum
      The ability to respond to change is Agile, through a
       highly structured approach
      New ways of working: Pair programming, test-driven
       development
Domain Driven Design                                          5




How does DDD Help?
   Communication improved by ubiquitous language
       Between team and client
       All the way through to the code


   Design thinking improved by applying standard patterns
       Leverage off the wisdom of others
       Double edged sword if a pattern is mis-identified


   Ensure design and reality match
       Model stories and scenarios using concrete examples
       Refactor, refactor…
Domain Driven Design                                       6




Ubiquitous Language
 Evolve the language, don’t define it upfront
      Client, customer, user, stakeholder, person,
       accountholder, payer ???
      Bounded context


 Bridge the IT/Domain expert divide
      Remove technical aspects (server, logger etc)
      No technical jargon (stored proc, XML etc)
      Clarify business terms and insist on consistent usage
      Make it natural
Domain Driven Design                                                     7




In practice…
Domain Expert                       Developer
The correct risk factor must be     We can do that quite easily if we
used when we calculate the          create another adjustment type
insurance premium.                  and modify the stored proc.

What is this stored proc you talk   Never mind, it’s kind of like a
about?                              spreadsheet macro.

So how will this work as an         Well, we already have adjustment
adjustment?                         types for loyalty and zero-claim
                                    discounts, so we can add risk
                                    factor as another type.

But loyalty and zero-claim are      Well, all those things are handled
benefits, not discounts!            as adjustments in the system.
                                    Trust me!
Domain Driven Design                                              8




Ubiquitous Language Rules
 Let the model do the talking
      Look at the model (sketch) and tell a story
      Look at the code and tell the same story


 Define structured stories
      As a … I want … So that …
      Identify user value (start by understanding their world)


 Define specific scenarios that model
   behaviour we can test
      Given (/and)… When … Then …
Domain Driven Design                                       9




Doing it right
Business Story
   As a new customer
   I want to know how much extra my insurance will cost if I
   use my private car for business purposes
   So that I can check if I am still within budget

Scenario 1
   Given the market value of my car is R100,000
   And the car is used for private purposes only
   And the risk factor is 0.15% for cars valued R100,000
   When the premium is calculated
   Then the premium should be R150
Domain Driven Design                                  10




The Neglected Verb
Nouns are easy

KRS client in the Shipping industry defined
actions (verbs) for a crew transfer form:

Complete          -    Filled in
Accepted
Confirmed         -    Planner processes transfer
Authorized
Accepted          -    Manager approves transfer
Confirmed
Authorized        -    Ship is notified of transfer
Domain Driven Design                                      11




Considering a Model
Design emerges…
       Communication tool
       Patterns appear as you build the model

IEEE: Software Engineering is the application of a
systematic, disciplined, quantifiable approach to
development…

Tools don’t matter: UML, BPM, any sketch can be a model


YAGNI / KISS
Domain Driven Design                                    12




The Core Model
Layered approach:
       Presentation / User Interface
       Application Layer (stateless, eg. Menu items)
       Domain / Business Logic
       Infrastructure / Persistence (DB)


Identify contexts
Identify interfaces
Look for behaviour
Look for value
Domain Driven Design                                       13




Entities and Value Objects
Entities
       Nouns
       Identity
       eg. Person, Sale, Stock, Vehicle

Value Objects
       We care about what an object has, not what it is
       Immutable
       Lightweight
       eg. Calendar, Price, Age, Vehicle Type
Domain Driven Design                    14




In practice…
Create a quote for a hotel booking:
       Check in date, check out date
       Number of rooms
Domain Driven Design   15



    Entity




Value Object
Domain Driven Design    16




Mapping Patterns
Shared Kernel
Customer / Supplier
Conformist
Separate Ways
Anti-corruption Layer
  Aggregates
  Factories
  Repositories
Domain Driven Design   17




Aggregates
Domain Driven Design                              18




Exploring the Domain
Domains are often complex
Most domains have subtleties
You need to dig deep

Your design should improve as you go
       You have to refactor as you go

What happens if you implement the design
that you first thought of?
       You lock in your ignorance – Eric Evans
Domain Driven Design                                       19




In practice…

Scenario 1
   Given the market value of my car is R100,000
   And the car is used for private purposes only
   And the risk factor is 0.15% for cars valued R100,000
   When the premium is calculated
   Then the premium should be R150
Domain Driven Design                                                            20




In practice…
@Test
class CalcuatePremiumForCars {
    private CarPremiumCalculator calculator = new CarPremiumCalculator;
    public void carUsedForPrivateUseOnly() {
           // Given the market value of my car is R100,000
           Money marketValue = new Money(100000);
           // and the car is used for private purposes only
           boolean isForPrivateUse = true;
           // and the risk factor is currently 0.15% for cars valued R100,000
           calculator.addRiskFactor(1000000, 0.15);
           // When the premium is calculated
           Money premium = calculator.calculate(marketValue,
isForPrivateUse);
           // Then the premium should be R150
           assertEquals(new Money(150), premium);
    }
Domain Driven Design                                      21




Lessons from KRS
DDD isn’t just for architects
We teach DDD to our interns
It results in better software
       Forces developers to think in layers
       Concrete scenarios get developers closer to the true
        business requirements quicker
       Scenarios become your tests
       Ubiquitous language breaks down barriers between
        users and developers
       Better software becomes a habit
Domain Driven Design   22




             Questions?


www.krs.co.za
( (021) 681 2900
Lorraine Steyn:  lor@krs.co.za
Paul Johnson:    paul.johnson@krs.co.za

More Related Content

PPTX
Low code development platform
PPTX
Domain driven design
PDF
DDD - 1 - A gentle introduction to Domain Driven Design.pdf
PPTX
Domain Driven Design 101
PPTX
Domain Driven Design
PDF
Serverless ddd
PDF
DevDay2017 ESGI Essential DDD
PDF
Domain Driven Design Tactical Patterns
Low code development platform
Domain driven design
DDD - 1 - A gentle introduction to Domain Driven Design.pdf
Domain Driven Design 101
Domain Driven Design
Serverless ddd
DevDay2017 ESGI Essential DDD
Domain Driven Design Tactical Patterns

What's hot (20)

PDF
Desenvolvimento Seguro de Software - 10o Workshop SegInfo - Apresentação
PPTX
UI / UX Design Presentation
PPTX
Domain Driven Design
PDF
Writing Continuous Applications with Structured Streaming PySpark API
PPSX
Domain Driven Design
PDF
Domain driven design and model driven development
PDF
Scrum + bdd + ddd
PDF
General overview low code/ no code
PPTX
A Practical Guide to Domain Driven Design: Presentation Slides
PPTX
Microservices Decomposition Patterns
PDF
COSCUP 2016 Workshop : 快快樂樂學Neo4j
PDF
COMP 4010: Lecture11 AR Interaction
PPTX
Introduction to Microservices
PPTX
Clean architecture
PDF
Head Mounted Displays & Data Glasses: VDC-Whitepaper
PPTX
Hexagonal architecture with Spring Boot
PDF
D2 domain driven-design
PPTX
The Practice of Enterprise Architecture - 2nd Edition - Book Review
PDF
SEED - Halcyon Architecture
PDF
UX is Not Equal to UI Design
Desenvolvimento Seguro de Software - 10o Workshop SegInfo - Apresentação
UI / UX Design Presentation
Domain Driven Design
Writing Continuous Applications with Structured Streaming PySpark API
Domain Driven Design
Domain driven design and model driven development
Scrum + bdd + ddd
General overview low code/ no code
A Practical Guide to Domain Driven Design: Presentation Slides
Microservices Decomposition Patterns
COSCUP 2016 Workshop : 快快樂樂學Neo4j
COMP 4010: Lecture11 AR Interaction
Introduction to Microservices
Clean architecture
Head Mounted Displays & Data Glasses: VDC-Whitepaper
Hexagonal architecture with Spring Boot
D2 domain driven-design
The Practice of Enterprise Architecture - 2nd Edition - Book Review
SEED - Halcyon Architecture
UX is Not Equal to UI Design
Ad

Viewers also liked (6)

PPTX
DDD In Agile
PDF
Domain-driven design - tactical patterns
PDF
From legacy to DDD
DOCX
Sample Project Requirements Document – Library Blog
PDF
Example requirements specification
DOCX
Software requirements specification
DDD In Agile
Domain-driven design - tactical patterns
From legacy to DDD
Sample Project Requirements Document – Library Blog
Example requirements specification
Software requirements specification
Ad

Similar to Domain Driven Design in an Agile World (20)

PDF
Domain Driven Design
PPTX
Domain Driven Design
PPTX
Schibsted Spain - Day 1 - DDD Course
PPTX
How to Implement Domain Driven Design in Real Life SDLC
PDF
Introduction to Domain driven design
PPTX
Finding balance of DDD while your application grows
PDF
Domain Driven Design
PPTX
Building Maintainable PHP Applications.pptx
PDF
DDD pour une meilleure qualité du produit
PPT
Domain Driven Design Demonstrated
PDF
Introduction to-ddd
PPTX
Domain Driven Design
PDF
SOAT Agile Day 2017 DDD
PPTX
Arch CoP - Domain Driven Design.pptx
PDF
Software design with Domain-driven design
PPTX
Domain Driven Design
PPTX
Up to speed in domain driven design
PDF
Modelling a complex domain with Domain-Driven Design
PPTX
Domain Driven Design
PPTX
Introduction to DDD
Domain Driven Design
Domain Driven Design
Schibsted Spain - Day 1 - DDD Course
How to Implement Domain Driven Design in Real Life SDLC
Introduction to Domain driven design
Finding balance of DDD while your application grows
Domain Driven Design
Building Maintainable PHP Applications.pptx
DDD pour une meilleure qualité du produit
Domain Driven Design Demonstrated
Introduction to-ddd
Domain Driven Design
SOAT Agile Day 2017 DDD
Arch CoP - Domain Driven Design.pptx
Software design with Domain-driven design
Domain Driven Design
Up to speed in domain driven design
Modelling a complex domain with Domain-Driven Design
Domain Driven Design
Introduction to DDD

More from Lorraine Steyn (11)

PPTX
Writing Better Code - Helping Developers make Decisions.pptx
PPTX
Systems Thinking Introduction - a quick overview for Software Practitioners
PPTX
Applying Systems Thinking to Teams and Software.pptx
PPTX
Applying Systems Thinking in Teams.pptx
PPTX
Systems Thinking and the Art of Simplification
PPTX
DDD Introduction
PPTX
Systems Thinking 2019
PPTX
Pair Programming
PPTX
Homo naledi - highlights from the paper published on eLife
PPTX
Fighting Facebook (social media marketing)
PPTX
Entrepreneurially Agile
Writing Better Code - Helping Developers make Decisions.pptx
Systems Thinking Introduction - a quick overview for Software Practitioners
Applying Systems Thinking to Teams and Software.pptx
Applying Systems Thinking in Teams.pptx
Systems Thinking and the Art of Simplification
DDD Introduction
Systems Thinking 2019
Pair Programming
Homo naledi - highlights from the paper published on eLife
Fighting Facebook (social media marketing)
Entrepreneurially Agile

Recently uploaded (20)

PDF
Machine learning based COVID-19 study performance prediction
PPTX
Machine Learning_overview_presentation.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPT
Teaching material agriculture food technology
PDF
Getting Started with Data Integration: FME Form 101
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Tartificialntelligence_presentation.pptx
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Encapsulation_ Review paper, used for researhc scholars
Machine learning based COVID-19 study performance prediction
Machine Learning_overview_presentation.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Spectral efficient network and resource selection model in 5G networks
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Teaching material agriculture food technology
Getting Started with Data Integration: FME Form 101
cloud_computing_Infrastucture_as_cloud_p
Reach Out and Touch Someone: Haptics and Empathic Computing
OMC Textile Division Presentation 2021.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Tartificialntelligence_presentation.pptx
A comparative analysis of optical character recognition models for extracting...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Unlocking AI with Model Context Protocol (MCP)
Diabetes mellitus diagnosis method based random forest with bat algorithm
Encapsulation_ Review paper, used for researhc scholars

Domain Driven Design in an Agile World

  • 1. DOMAIN DRIVEN DESIGN Prepared for the 4th Software Engineering Colloquium Lorraine Steyn and Paul Johnson
  • 2. Domain Driven Design 2 Home Truths A design should be as simple as possible, but no simpler Agile development is about collaboration and communication
  • 3. Domain Driven Design 3 Agile, briefly Agile practitioners can be design avoidant!  Avoid documentation, no big upfront analysis Scrum and Agile encourage rapid change  Quicker route to the BOM  No time for design?  Small user stories lose the big picture  Scrum is particularly Process focused, and does not prescribe the technical approach
  • 4. Domain Driven Design 4 Agile – the good bits Short iterations  Deliver working software in 2 to 3 week “sprints” Empower people  Team ownership  Team commitment to deliver Structured Process through Scrum  The ability to respond to change is Agile, through a highly structured approach  New ways of working: Pair programming, test-driven development
  • 5. Domain Driven Design 5 How does DDD Help?  Communication improved by ubiquitous language  Between team and client  All the way through to the code  Design thinking improved by applying standard patterns  Leverage off the wisdom of others  Double edged sword if a pattern is mis-identified  Ensure design and reality match  Model stories and scenarios using concrete examples  Refactor, refactor…
  • 6. Domain Driven Design 6 Ubiquitous Language  Evolve the language, don’t define it upfront  Client, customer, user, stakeholder, person, accountholder, payer ???  Bounded context  Bridge the IT/Domain expert divide  Remove technical aspects (server, logger etc)  No technical jargon (stored proc, XML etc)  Clarify business terms and insist on consistent usage  Make it natural
  • 7. Domain Driven Design 7 In practice… Domain Expert Developer The correct risk factor must be We can do that quite easily if we used when we calculate the create another adjustment type insurance premium. and modify the stored proc. What is this stored proc you talk Never mind, it’s kind of like a about? spreadsheet macro. So how will this work as an Well, we already have adjustment adjustment? types for loyalty and zero-claim discounts, so we can add risk factor as another type. But loyalty and zero-claim are Well, all those things are handled benefits, not discounts! as adjustments in the system. Trust me!
  • 8. Domain Driven Design 8 Ubiquitous Language Rules  Let the model do the talking  Look at the model (sketch) and tell a story  Look at the code and tell the same story  Define structured stories  As a … I want … So that …  Identify user value (start by understanding their world)  Define specific scenarios that model behaviour we can test  Given (/and)… When … Then …
  • 9. Domain Driven Design 9 Doing it right Business Story As a new customer I want to know how much extra my insurance will cost if I use my private car for business purposes So that I can check if I am still within budget Scenario 1 Given the market value of my car is R100,000 And the car is used for private purposes only And the risk factor is 0.15% for cars valued R100,000 When the premium is calculated Then the premium should be R150
  • 10. Domain Driven Design 10 The Neglected Verb Nouns are easy KRS client in the Shipping industry defined actions (verbs) for a crew transfer form: Complete - Filled in Accepted Confirmed - Planner processes transfer Authorized Accepted - Manager approves transfer Confirmed Authorized - Ship is notified of transfer
  • 11. Domain Driven Design 11 Considering a Model Design emerges…  Communication tool  Patterns appear as you build the model IEEE: Software Engineering is the application of a systematic, disciplined, quantifiable approach to development… Tools don’t matter: UML, BPM, any sketch can be a model YAGNI / KISS
  • 12. Domain Driven Design 12 The Core Model Layered approach:  Presentation / User Interface  Application Layer (stateless, eg. Menu items)  Domain / Business Logic  Infrastructure / Persistence (DB) Identify contexts Identify interfaces Look for behaviour Look for value
  • 13. Domain Driven Design 13 Entities and Value Objects Entities  Nouns  Identity  eg. Person, Sale, Stock, Vehicle Value Objects  We care about what an object has, not what it is  Immutable  Lightweight  eg. Calendar, Price, Age, Vehicle Type
  • 14. Domain Driven Design 14 In practice… Create a quote for a hotel booking:  Check in date, check out date  Number of rooms
  • 15. Domain Driven Design 15 Entity Value Object
  • 16. Domain Driven Design 16 Mapping Patterns Shared Kernel Customer / Supplier Conformist Separate Ways Anti-corruption Layer Aggregates Factories Repositories
  • 17. Domain Driven Design 17 Aggregates
  • 18. Domain Driven Design 18 Exploring the Domain Domains are often complex Most domains have subtleties You need to dig deep Your design should improve as you go  You have to refactor as you go What happens if you implement the design that you first thought of?  You lock in your ignorance – Eric Evans
  • 19. Domain Driven Design 19 In practice… Scenario 1 Given the market value of my car is R100,000 And the car is used for private purposes only And the risk factor is 0.15% for cars valued R100,000 When the premium is calculated Then the premium should be R150
  • 20. Domain Driven Design 20 In practice… @Test class CalcuatePremiumForCars { private CarPremiumCalculator calculator = new CarPremiumCalculator; public void carUsedForPrivateUseOnly() { // Given the market value of my car is R100,000 Money marketValue = new Money(100000); // and the car is used for private purposes only boolean isForPrivateUse = true; // and the risk factor is currently 0.15% for cars valued R100,000 calculator.addRiskFactor(1000000, 0.15); // When the premium is calculated Money premium = calculator.calculate(marketValue, isForPrivateUse); // Then the premium should be R150 assertEquals(new Money(150), premium); }
  • 21. Domain Driven Design 21 Lessons from KRS DDD isn’t just for architects We teach DDD to our interns It results in better software  Forces developers to think in layers  Concrete scenarios get developers closer to the true business requirements quicker  Scenarios become your tests  Ubiquitous language breaks down barriers between users and developers  Better software becomes a habit
  • 22. Domain Driven Design 22 Questions? www.krs.co.za ( (021) 681 2900 Lorraine Steyn: lor@krs.co.za Paul Johnson: paul.johnson@krs.co.za