7 Years of Domain-Driven Design

7 Years of Domain-Driven Design

It turns out that domain-driven design works for more than just cargo shipping. Vladik Khononov shares his experience using the domain-driven design methodology at Plexop, a large-scale marketing system that spans over a dozen of different business domains, from the management of advertising spaces to sales agents’ commissions. Vladik and his team had very limited resources and a very short time to market to implement Plexop. He explains how DDD allowed them to manage complexities, discusses different strategies for defining context boundaries, and of course, details the lessons that they learned the hard way.

B90ab53ba7cf16ed1a4bb679cc6751d7?s=128

Vladik Khononov

October 30, 2018
Tweet

Transcript

  1. 2.
  2. 5.
  3. 9.
  4. 10.
  5. 13.

    vladikk Aggregates everywhere!!! Creative Agency Advertiser Publisher Website Placement Ad

    Zone Ad Type Target Market Group Zone Type Funnel Contract Budget Unit Campaign
  6. 14.

    vladikk The Bounded Context Creative Agency Advertiser Publisher Website Placement

    Ad Zone Ad Type Target Market Group Zone Type Funnel Contract Budget Unit Audience
  7. 24.
  8. 28.

    vladikk Creative Agency Publisher Website Advertiser Ad Zone Ad Type

    Target Market Group Zone Type Funnel Contract Budget Unit Audience Group Desk Qualification Assessment Organization Unit Assignment Rank Message On-site Activity Placement Visit Brand Marketing Lead CRM Lead Marketing Campaign CRM Campaign
  9. 30.
  10. 31.
  11. 33.

    vladikk Creative Agency Publisher Website Advertiser Ad Zone Ad Type

    Target Market Group Zone Type Funnel Contract Budget Unit Audience Group Desk Qualification Assessment Organization Unit Assignment Rank Message On-site Activity Placement Visit Brand Marketing Lead CRM Lead Marketing Campaign CRM Campaign
  12. 34.

    vladikk Creative Agency Publisher Website Advertiser Ad Zone Ad Type

    Target Market Group Zone Type Funnel Contract Budget Unit Audience Placement Visit Lead Campaign Marketing Group Desk Qualification Assessment Organization Unit Assignment Rank Message On-site Activity Brand Lead Campaign CRM
  13. 35.

    vladikk Aggregates will:
 • Protect transactional boundaries
 • Encompass business

    logic and invariants Domain Service / Application Layer Presentation Infrastructure
  14. 36.

    vladikk Aggregates will:
 • Protect transactional boundaries
 • Encompass business

    logic and invariants Domain Service / Application Layer Presentation Infrastructure Domain Service / Application Layer
  15. 37.
  16. 38.
  17. 39.
  18. 43.
  19. 54.
  20. 62.

    vladikk Sales Commissions Reports Let’s try different percentages What if

    the percentage could be a function of a price? No, what if the percentage is a function of number of sales? No, no, the percentage will be a function both of number of sales and sale amount And another upgrade if there are more than Y sales per week! But we will upgrade the percentage if there are more than X sales per month!
  21. 65.

    vladikk Active Record Service / Application Layer Presentation Infrastructure Transaction

    Script Service / Application Layer Presentation Infrastructure Event Crunchers Bonuses Ubiquitous Language
  22. 66.

    vladikk Ubiquitous Language Core Bounded Contexts Protect by
 decomposing to

    Identify Domains Domain Model Supporting Generic AR / TS Adopt Implement as
  23. 79.

    Marketing Bonuses U D CRM U D Marketing
 Hub U

    U D D Event Crunchers U D U D
  24. 83.

    vladikk Marketing Ubiquitous Language Business goals achieved CRM Ubiquitous Language

    Production issues Long and painful refactoring Event Crunchers Ubiquitous Language Big ball of mud Bonuses Ubiquitous Language Refactored in time
  25. 85.

    vladikk Marketing Ubiquitous Language Business goals achieved CRM Ubiquitous Language

    Production issues Long and painful refactoring Event Crunchers Ubiquitous Language Big ball of mud Bonuses Ubiquitous Language Refactored in time
  26. 89.

    vladikk Generic Domain Adopt / Buy Supporting Domain Active Record

    / Transaction Script Core Domain Domain Model / Event Sourcing
  27. 91.

    vladikk SUPPORTING ➤ CORE • Event Crunchers • Bonuses SUPPORTING

    ➤ GENERIC • Creative Catalog CORE ➤ GENERIC • Lead Evaluation System CORE ➤ SUPPORTING • Marketing Hub GENERIC ➤ CORE • AWS
  28. 92.

    vladikk Generic Domain Adopt / Buy Supporting Domain Active Record

    / Transaction Script Core Domain Domain Model / Event Sourcing
  29. 93.

    vladikk Generic Domain Adopt / Buy Supporting Domain Active Record

    / Transaction Script Core Domain Domain Model / Event Sourcing
  30. 95.

    vladikk • Questionable competitive edge? • Accidental “business” complexity? •

    Unexpected competitive edge? BUSINESS COMPLEXITY ≠ DOMAIN TYPE?
  31. 96.

    vladikk Generic Domain Adopt / Buy Supporting Domain Active Record

    / Transaction Script Core Domain Domain Model / Event Sourcing IMPLEMENTATION DESIGN ➤ DOMAIN TYPE
  32. 99.

    vladikk How to Model the Business Logic? Transaction Script (PoEAA)

    Active Record (PoEAA) Domain Model (PoEAA + DDD) Event Sourced Domain Model
  33. 100.

    vladikk MONEY? DEEP ANALYTICS? AUDIT LOG? Event Sourced Domain Model

    COMPLEX BUSINESS LOGIC? Domain Model COMPLEX DATA STRUCTURES? Active Record SIMPLE LOGIC, SIMPLE DATA STRUCTURES? Transaction Script
  34. 101.

    vladikk MAPPING ARCHITECTURAL PATTERNS Event Sourced Domain Model ➤ CQRS

    Domain Model ➤ Hexagonal Architecture Active Record ➤ Layered Architecture Transaction Script ➤ “Keep it simple” Architecture
  35. 102.

    vladikk MAPPING ARCHITECTURAL PATTERNS Event Sourced Domain Model ➤ CQRS

    Domain Model ➤ Hexagonal Architecture Active Record ➤ Layered Architecture Transaction Script ➤ “Keep it simple” Architecture
  36. 108.

    vladikk EVENT SOURCING BUSINESS DOMAIN MODELING PATTERN CQRS ARCHITECTURAL PATTERN

    FOR REPRESENTING DATA IN DIFFERENT PERSISTENT MODELS
  37. 109.
  38. 110.

    vladikk RDBMS Search index Files
 storage Projection
 Engine Projected
 Model

    Projected
 Model Changes Application Query Query Commit
  39. 112.

    vladikk Did command succeed or fail? If failed - why?

    What are the outcomes? } Can be delivered asynchronously through queries … but why?
  40. 113.

    vladikk Write
 Model Projection Projection Projection
 Engine Projected
 Model Projected


    Model Changes Application Client Command
 Execution Result Query
  41. 115.

    vladikk Creative Agency Publisher Website Advertiser Ad Zone Ad Type

    Target Market Group Zone Type Funnel Contract Budget Unit Audience Placement Visit Lead Campaign Marketing Group Desk Qualification Assessment Organization Unit Assignment Rank Message On-site Activity Brand Lead Campaign CRM LINGUISTIC BOUNDARIES
  42. 119.
  43. 122.

    vladikk Creative Agency Publisher Website Advertiser Ad Zone Ad Type

    Target Market Group Zone Type Funnel Contract Budget Unit Audience Group Desk Qualification Assessment Organization Unit Assignment Rank Message On-site Activity Placement Visit Brand Marketing Lead CRM Lead Marketing Campaign CRM Campaign
  44. 123.

    vladikk MICROSERVICES DECOMPOSITION OF A SYSTEM INTO LOOSELY COUPLED COMPONENTS

    BOUNDED CONTEXTS PROTECT INTEGRITY OF A UBIQUITOUS LANGUAGE
  45. 127.

    vladikk THE LESS YOU KNOW ABOUT THE DOMAIN THE WIDER

    THE INITIAL BOUNDARIES START WITH BIGGER BOUNDARIES DECOMPOSE LATER, AS YOU GAIN KNOWLEDGE
  46. 129.

    vladikk Marketing Creative Agency Publisher Website Advertiser Ad Zone Ad

    Type Target Market Group Zone Type Funnel Contract Budget Unit Audience Placement Visit Lead Campaign
  47. 130.

    vladikk Campaigns Creative Ad Type Agency Publisher Website Zone Type

    Contract Budget Unit Impression Visit Lead Advertiser Target Market Funnel Audience Placement Campaign Creative Catalog Publishers Events
  48. 132.

    vladikk 1. Ubiquitous Language is not optional 2. Domain Types

    change. Embrace these changes to achieve resilient design 3. Learn the ins and outs of the four patterns of modeling business logic 4. Use CQRS to represent the same data in multiple models 5. Bounded Contexts are not Microservices. Always start with bigger boundaries, but decompose further as you gain domain knowledge
  49. 134.

    vladikk Ubiquitous Language Bounded Contexts Protect by
 decomposing to Design


    Implementation Core Supporting Generic Domain Model AR / TS Adopt Confirm w/
 Business
  50. 135.

    vladikk Ubiquitous Language Bounded Contexts Protect by
 decomposing to Design


    Implementation Core Supporting Generic Domain Model AR / TS Adopt Confirm w/
 Business
  51. 136.

    vladikk Ubiquitous Language Bounded Contexts Protect by
 decomposing to Design


    Implementation Core Supporting Generic Domain Model AR / TS Adopt Confirm w/
 Business
  52. 137.

    vladikk Ubiquitous Language Bounded Contexts Protect by
 decomposing to Design


    Implementation Core Supporting Generic Domain Model AR / TS Adopt Confirm w/
 Business
  53. 138.

    vladikk Ubiquitous Language Bounded Contexts Protect by
 decomposing to Design


    Implementation Core Supporting Generic Domain Model AR / TS Adopt Confirm w/
 Business
  54. 139.

    vladikk Creative Agency Advertiser Publisher Website Placement Ad Zone Ad

    Type Target Market Group Zone Type Funnel Contract Budget Unit Campaign Aggregates everywhere!!!
  55. 140.

    vladikk Ubiquitous Language Bounded Contexts Protect by
 decomposing to Design


    Implementation Core Supporting Generic Domain Model AR / TS Adopt Confirm w/
 Business Ubiquitous Language Everywhere!!!
  56. 142.