Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The strategies behind ddd – AdeoDevSummit 2022

The strategies behind ddd – AdeoDevSummit 2022

Have you ever experienced that a small change in the business triggers an apocalyptic change in the software code? These kinds of symptoms are often a symptom of software architecture and business misalignment.
In this talk we will see how to enable developers to express business concerns in the software architecture in order to prevent a wide range of problems. Issues that cause particularly harmful side-effects and can prevent an efficient refactoring policy.
This introduction to the strategic aspects of Domain Driven Design is not a purely technical presentation, and is therefore aimed at both developers and all stakeholders involved in software design.

Arnaud LEMAIRE
PRO

June 22, 2022
Tweet

More Decks by Arnaud LEMAIRE

Other Decks in Programming

Transcript

  1. www.lilobase.me
    The strategies
    behind DDD
    @lilobase
    #DevSummit
    sundayapp.com

    View Slide

  2. Let’s start a new project !

    View Slide

  3. Sprint Zero
    Java or C# ?
    Spring Boot or
    Quarkus ?
    Kafka
    or Redis ?
    Microservices
    or Monolith ?
    Kubernetes
    or Nomad ?
    Angular
    or React ?

    View Slide

  4. Look, at our spring
    boot application with
    Kafka deployed on a K8S
    Cluster
    They know nothing
    about the project’s business
    domain

    Sprint Zero

    View Slide

  5. Java or C# ?
    Spring Boot or
    Quarkus ?
    Kafka
    or Redis ?
    Microservices
    or Monolith ?
    Kubernetes
    or Nomad ?
    Angular
    or React ?
    These issues address only
    the solution

    View Slide

  6. But not the problem
    What should we do ?

    View Slide

  7. Spring Boot or
    Quarkus ?
    Kafka
    or Redis ?
    Microservices
    or Monolith ?
    Kubernetes
    or Nomad ?
    Angular
    or React ?
    And that's why we


    are seen as technical expert
    Java or C# ?

    View Slide

  8. solution
    problem
    What should we do ?
    How are we going to do it ?
    It is an important discussion to have
    But only after we've
    fi
    gured out

    what to do

    View Slide

  9. DDD is all about
    Alignment
    What should we do ?
    How are we going to do it ?

    View Slide

  10. DDD is all about
    Alignment
    What should we do ?
    How are we going to do it ?

    View Slide

  11. « Give a child a hammer and
    everything they meets has to be
    pounded. »
    – Abraham Kaplan

    View Slide

  12. « We put the needs
    of the database
    before the needs of
    the users, which
    results in some
    pretty crappy
    experiences »
    – @WalterStephanie

    View Slide

  13. www.lilobase.me
    DDD is all about
    Understanding
    @lilobase

    View Slide

  14. Domains & Subdomains
    Business Domain discovery
    THE software

    View Slide

  15. Domain Mapping
    Business Domain Classi
    fi
    cation
    Authoring


    &


    Publishing
    Customer Care
    Printing &


    Supply Chain
    Retail Store
    You need to acknowledge the fact that
    you have several domains

    View Slide

  16. Domain Mapping
    Business Domain Classi
    fi
    cation
    Authoring


    &


    Publishing
    Customer Care
    Printing &


    Supply Chain
    Retail Store
    Only one VP should be


    angry at a time

    View Slide

  17. Domain Mapping
    Business Domain Classi
    fi
    cation
    Authoring


    &


    Publishing
    Customer Care
    Printing &


    Supply Chain
    Retail Store
    These are neither Bounded
    Contexts nor Microservices

    View Slide

  18. Domain Mapping
    Business Domain Classi
    fi
    cation
    Authoring


    &


    Publishing
    Customer Care
    Printing &


    Supply Chain
    Retail Store
    These are your domains

    View Slide

  19. Domain Mapping
    Business Domain Classi
    fi
    cation
    Authoring


    &


    Publishing
    Customer
    Care
    Printing &


    Supply Chain
    Online Retail Store
    Payment
    processor
    Catalogue Invoicing
    Your domains contain domains

    View Slide

  20. Supporting
    Subdomain
    Generic
    Subdomain
    Core
    (sub)Domain
    Key differentiator
    Domains & Subdomains
    Business Domain Classi
    fi
    cation
    Essential to the

    organization’s success
    Required for the

    organization’s success
    Critical to the

    organization’s success

    View Slide

  21. Domain Mapping
    Business Domain Classi
    fi
    cation
    Authoring
    Plateform
    Publishing &
    Printing
    Inventory
    Management
    Payment
    Processor
    Catalogue
    Invoicing
    Shipping
    Order
    Processing
    Proofreading

    View Slide

  22. Domains & Subdomains
    Business Domain Classi
    fi
    cation
    Authoring
    Plateform
    Inventory
    Management
    Shipping
    Payment
    Processor
    Catalogue
    Invoicing
    Order
    Processing
    Publishing &
    Printing
    Proofreading

    View Slide

  23. Domains & Subdomains
    Business Domain Classi
    fi
    cation
    Authoring
    Plateform
    Inventory
    Management
    Payment
    Processor
    Catalogue
    Invoicing
    Each business context is speci
    fi
    c
    Shipping
    Order
    Processing
    Publishing &
    Printing
    Proofreading

    View Slide

  24. Authoring
    Plateform
    Domains’ Connexion
    Reveal Business Relationships
    Inventory
    Management
    Shipping
    Catalogue
    Invoicing
    Order
    Processing
    Payment
    Processor
    It can highlight signi
    fi
    cant

    sub-domain
    Publishing &
    Printing
    Proofreading

    View Slide

  25. www.lilobase.me
    DDD is all about
    Context
    @lilobase

    View Slide

  26. From Problem to Solution
    Authoring
    Plateform
    Publishing
    & Printing
    Inventory
    Management
    Shipping
    Payment
    Processor
    Catalogue
    Invoicing
    Order
    Processing
    Proofreading

    View Slide

  27. From Problem to Solution
    Authoring
    Plateform
    Publishing
    & Printing
    Inventory
    Management
    Shipping
    Payment
    Processor
    Catalogue
    Invoicing
    Order
    Processing
    problem
    solution
    Payment
    processor
    Invoicing
    Order
    Processing
    Shipping
    Authoring
    Plateforme
    Inventory
    Management
    Catalogue
    Publishing
    Proofreading
    Proofreading
    Inventory E-commerce platform
    Authoring
    Publishing

    View Slide

  28. Domains & Subdomains
    Development Strategy
    Supporting
    Subdomain
    In-House development with

    external support if possible
    Generic
    Subdomain
    Outsourcing is an option
    Core
    (sub)Domain
    In-House development

    with Your best teams
    Key differentiator

    View Slide

  29. Domains & Subdomains
    Development Strategy
    Supporting
    Subdomain
    Customized Off The Shelf Software

    is an option
    Generic
    Subdomain
    Try to
    fi
    nd Off The Shelf solution


    Cost saving opportunities
    Core
    (sub)Domain
    Custom-made software


    High Cost & Quality
    Key differentiator

    View Slide

  30. From Problem to Solution
    Payment
    processor
    Invoicing
    Order
    Processing
    Shipping
    Authoring
    Plateforme
    Inventory
    Management
    Catalogue
    Publishing
    Proofreading
    Inventory E-commerce platform
    Authoring
    Publishing
    Authoring
    Plateform
    Publishing
    & Printing
    Inventory
    Management
    Shipping
    Payment
    Processor
    Catalogue
    Invoicing
    Order
    Processing
    Proofreading

    View Slide

  31. From Problem to Solution
    Inventory E-commerce platform
    Authoring
    Authoring
    Plateforme Publishing
    Catalogue
    Publishing
    Proofreading
    Authoring
    Plateform
    Publishing
    & Printing
    Inventory
    Management
    Shipping
    Payment
    Processor
    Catalogue
    Invoicing
    Order
    Processing
    Proofreading

    View Slide

  32. From Problem to Solution
    Business Domain & Architecture alignment
    Inventory E-commerce


    platform
    Authoring
    Authoring
    Plateforme Publishing
    Catalogue
    Publishing
    Proofreading
    These are your bounded contexts

    View Slide

  33. Inventory E-commerce


    platform
    Authoring
    Publishing
    Align your teams with your
    bounded context
    « Team assignments are the
    fi
    rst
    draft of the architecture »
    – Michael Nygard

    View Slide

  34. P
    Authoring
    Publishing
    E-commerce
    Stripe
    ShipMonk Shopify
    Context Mapping
    Relationship Hierarchy
    OHS
    OHS
    ACL
    OHS
    C/S

    View Slide

  35. Authoring
    Publishing
    E-commerce
    Specific Architecture style
    You don’t need one architectural style
    Beware of the CRUD
    ES
    CQRS
    CRUD ?
    Stripe
    ShipMonk Shopify

    View Slide

  36. Stripe
    Still no microservices
    Bounded Context ≠ Deployment units
    ShipMonk
    Authoring
    Publishing
    E-commerce
    Shopify
    Deployment Unit

    View Slide

  37. Deployment Unit
    Stripe
    Still no microservices
    Bounded Context ≠ Deployment units
    ShipMonk
    Authoring
    Publishing
    E-commerce
    Shopify
    Deployment Unit

    View Slide

  38. Domains are not immutable
    Understanding is a never-ending process
    Stripe
    ShipMonk
    Authoring
    Publishing
    E-commerce
    Shopify
    Printing

    View Slide

  39. www.lilobase.me
    DDD is all about
    Boundaries
    @lilobase

    View Slide

  40. Semantic Boundaries
    Between BC meaning are different
    Authoring Publishing
    Book
    Chapter
    Chapter
    They are not the same book
    What
    happens if
    the author
    revises his
    book?

    View Slide

  41. Semantic Boundaries
    Between BC meaning are different
    Chapter
    This is why you must start by understand
    strategically your domain
    Author
    Book
    Reviews
    Release
    Catalogue

    View Slide

  42. Semantic Boundaries
    Between BC meaning are different
    Authoring Publishing
    Book
    Chapter
    Chapter
    Book
    Chapter
    Chapter
    Inside a
    Bounded
    Context,

    Don’t

    Repeat

    Yourself
    Between
    Bounded
    Context,

    Write

    Everything

    Twice

    View Slide

  43. Don’t cross them
    Between BC meaning are different
    Authoring Publishing
    Author
    Reviews
    Author
    Book Book
    Release
    Never create relationships
    between entities from two BC

    View Slide

  44. Don’t cross them
    Between BC meaning are different
    Authoring Publishing
    Book Book
    Release
    Author
    Author
    Reviews
    This is exactly the same

    View Slide

  45. Don’t cross them
    Between BC meaning are different
    Authoring Publishing
    Book Book
    Release
    Author
    Author
    Reviews
    API API

    View Slide

  46. Same for Events
    Between BC meaning are different
    Authoring Publishing
    This is exactly the same
    Event

    Bus
    Book Book
    Release
    Author
    Author
    Reviews

    View Slide

  47. Same for Events
    Between BC meaning are different
    Authoring Publishing
    Event

    Bus
    Book Book
    Release
    Author
    Author
    Reviews
    Translator Translator

    View Slide

  48. Transactional Boundaries
    Protect your integrity
    Authoring
    Book
    Chapter
    Chapter
    Chapter
    Statistics
    Inside your
    bounded
    Context

    live

    Entities
    They are
    grouped in
    Aggregates

    View Slide

  49. Transactional Boundaries
    Protect your integrity
    Book
    Chapter
    Chapter
    Chapter
    Statistics
    They are
    retrieved
    and
    persisted

    as a whole
    Inside an
    aggregate,
    Entities

    share the
    same
    lifecycle

    View Slide

  50. Transactional Boundaries
    Protect your integrity
    Book
    Chapter
    Chapter
    Chapter
    Statistics
    Who
    ensures the
    aggregate
    integrity
    All
    interactions
    are done
    through the
    Aggregate
    Root
    Write a new chapter

    View Slide

  51. Transactional Boundaries
    Protect your integrity
    Book
    Chapter
    Chapter
    Chapter
    Statistics
    Write a new chapter
    Chapter
    Inconsistency

    View Slide

  52. Transactional Boundaries
    Protect your integrity
    Book
    Chapter
    Chapter
    Chapter
    Statistics
    But don’t
    put to much
    in it
    Author
    What
    happens if
    we delete
    the book ?
    They must share the same lifecycle

    View Slide

  53. Transactional Boundaries
    Protect your integrity
    Book
    Chapter
    Chapter
    Chapter
    Statistics
    Author
    reference
    Author
    Id

    View Slide

  54. Designing Boundaries
    Protect your domain
    Printing Team
    We need printing
    margin
    Book
    Chapter
    Chapter
    Chapter
    Release
    We need the
    colorimetric pro
    fi
    le
    Printing
    margin
    Colorimetric
    pro
    fi
    le
    API
    Publishing Team

    View Slide

  55. Designing Boundaries
    Protect your domain
    API
    We need printing
    margin
    Book
    Chapter
    Chapter
    Chapter
    Release
    We need the
    colorimetric pro
    fi
    le
    Printing
    margin
    Colorimetric
    pro
    fi
    le
    Domain Leakage
    Publishing Team Printing Team

    View Slide

  56. Designing Boundaries
    Protect your domain
    Publishing Team Printing Team
    Publishing
    API
    We need
    printing margin
    Book
    We need the
    colorimetric
    pro
    fi
    le
    Printing
    margin
    Colorimetric
    pro
    fi
    le
    Printing API
    We discovered the need

    for an ACL

    View Slide

  57. www.lilobase.me
    DDD is all about
    Behavior
    @lilobase

    View Slide

  58. CRUD don’t express behavior
    It blinds you from the business perspective
    UPDATE address
    Relocation Mistake correction

    View Slide

  59. CRUD don’t express behavior
    It blinds you from the business perspective
    Relocation Mistake correction

    View Slide

  60. Data oriented programming
    It obfuscates your code
    – Mathias Verraes
    $order->setStatus('paid');
    $order->setPaidAmount(120);
    $order->setPaidCurrency('EUR');
    $order->setCustomer($customer);

    View Slide

  61. Data oriented programming
    It obfuscates your code
    $money = new Money(120, new Currency(‘EUR'));
    $order->pay($customer, $money);
    – Mathias Verraes
    $customer->pay($order, $money);

    View Slide

  62. Data oriented programming
    It obfuscates your code
    – Mathias Verraes
    $customer->pay($order, $money);
    $order->setStatus('paid');
    $order->setPaidAmount(120);
    $order->setPaidCurrency('EUR');
    $order->setCustomer($customer);

    View Slide

  63. Task Based UI
    Your customer’s need isn’t to
    fi
    ll out forms

    View Slide

  64. Users don’t need to fill out forms

    View Slide

  65. Users don’t need to fill out forms

    View Slide

  66. www.lilobase.me
    DDD is all about
    Compassion
    @lilobase

    View Slide

  67. A A
    A
    Ubiquitous language
    Stakeholders & Team Alignement
    Dev Domain

    Expert
    Dev

    View Slide

  68. A A
    A
    not « just » a glossary
    Ubiquitous language
    Stakeholders & Team Alignement
    Dev Domain

    Expert
    Dev

    View Slide

  69. Ubiquitous language
    Each BC has its own
    Authoring Publishing
    A A

    View Slide

  70. Ubiquitous language
    Each BC has its own
    Authoring Publishing
    A A
    A A
    It is a common cause of
    miscommunication

    View Slide

  71. Pair Programing
    The best way to share a domain understanding
    Dev Domain

    Expert

    View Slide

  72. Know your users
    They might not be who you think they are
    Dev Domain

    Expert
    Product

    Owner
    Customer User

    View Slide

  73. Know your users
    They might not be who you think they are
    Dev Domain

    Expert
    Product

    Owner
    Customer User
    He has the last word regarding
    domain implementation

    View Slide

  74. Know your users
    They might not be who you think they are
    Dev Domain

    Expert
    Product

    Owner
    Customer User
    Prioritize development &
    formalize users’ feedback

    View Slide

  75. Know your users
    They might not be who you think they are
    Dev Domain

    Expert
    Product

    Owner
    Customer User
    Power of Life and Death over the
    project

    View Slide

  76. Know your users
    They might not be who you think they are
    Dev Domain

    Expert
    Product

    Owner
    Customer User
    Too often forgotten

    View Slide

  77. Know your users
    They might not be who you think they are
    Dev Domain

    Expert
    Product

    Owner
    Customer User
    Maybe you could spend a day per
    month working with them ?

    View Slide

  78. Know your users
    They might not be who you think they are
    Dev Domain

    Expert
    Product

    Owner
    Customer User
    They design the software
    speci
    fi
    cation

    View Slide

  79. Know your users
    They might not be who you think they are
    Dev Domain

    Expert
    Product

    Owner
    Customer User
    What he understood goes

    into production

    View Slide

  80. www.lilobase.me
    DDD is for every
    Projects
    @lilobase

    View Slide

  81. “A loosely coupled software
    architecture and org
    structure to match” is a key
    predictor of:


    • Continuous Delivery
    Performance


    • Ability to scale
    organization and increase
    performance linearly
    This is what DDD is All About !
    — Michael Plöd (@bitboss)

    View Slide

  82. www.lilobase.me @lilobase
    sundayapp.com
    Thanks

    View Slide