Pro Yearly is on sale from $80 to $50! »

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. vladikk 7 YEARS OF DDD or Tackling Complexity in
 Large

    Scale Marketing Systems
  2. YAY!!!

  3. @vladikk vladikk.com Internovus

  4. vladikk PART 2 
 5 PRACTICAL ADVICES PART 1
 5

    BOUNDED CONTEXTS
  5. None
  6. vladikk Your Product Marketing
 Strategy Creatives Campaigns Sales
 Agents Optimization

    Profits
  7. vladikk THE FIRST BOUNDED CONTEXT 01

  8. vladikk Media Buying Creatives Catalog Campaign Management VER 1.0

  9. vladikk

  10. vladikk

  11. Very nice!!!1

  12. vladikk Aggregates everywhere!!!

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

    Zone Ad Type Target Market Group Zone Type Funnel Contract Budget Unit Campaign
  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
  15. vladikk Domain Model Service / Application Layer Presentation Infrastructure Anemic!

    Behaviour
  16. vladikk Imperfect architecture “QA is for cowards” BUT IT WORKED!

  17. vladikk UBIQUITOUS LANGUAGE

  18. vladikk Domain Experts Software Developers No experience in online marketing

    Nice people!
  19. vladikk Smooth communication Strong grasp of the business domain Working

    software Aggressive time to market
  20. vladikk Ubiquitous Language Anemic Domain Model

  21. vladikk Leads Sales Agents Ads

  22. vladikk Leads CRM Categorize Desk Desk Desk Sales Agents Sales

    Agents Sales Agents
  23. Leads CRM Categorize Desk Desk Desk Sales Agents Sales Agents

    Sales Agents Clients’ Systems
  24. vladikk

  25. vladikk Lead qualification Agent qualification Agents’ commissions

  26. vladikk THE CRM BOUNDED CONTEXT 02

  27. vladikk Ubiquitous Language Anemic Domain Model

  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
  29. vladikk Domain Experts Software Developers …. Lead …. …. Campaign…

  30. vladikk

  31. None
  32. vladikk BOUNDED CONTEXTS PROTECT THE LANGUAGE AGGREGATES PROTECT CONSISTENCY OF

    DATA
  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
  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
  35. vladikk Aggregates will:
 • Protect transactional boundaries
 • Encompass business

    logic and invariants Domain Service / Application Layer Presentation Infrastructure
  36. vladikk Aggregates will:
 • Protect transactional boundaries
 • Encompass business

    logic and invariants Domain Service / Application Layer Presentation Infrastructure Domain Service / Application Layer
  37. None
  38. vladikk

  39. None
  40. vladikk Stored procedures???

  41. vladikk Group Desk Qualification Assessment Organization Unit Assignment Rank Message

    On-site Activity Brand Lead Campaign Lead
  42. L e a d CRM Team DBA Team

  43. None
  44. vladikk Inconsistent models No shared understanding Duplication of knowledge Went

    out of sync quickly NIGHTMARE
  45. vladikk Wasn’t delivered on time Production issues Data corruption Thrown

    away and reimplemented
  46. vladikk Ubiquitous Language Domain Model Bounded Contexts Protect w/ Implement

    as
  47. Not all of a large system will be well designed

    “ Eric Evans
  48. vladikk THE CRUNCHERS BOUNDED CONTEXT 03

  49. vladikk Marketing CRM Analysis Customer Events Marketing CRM

  50. vladikk Marketing CRM Analysis Customer Events Event Crunchers

  51. vladikk Competitive advantage? - No Off-the-shelve solution? - No =>

    Supporting sub-domain
  52. vladikk Layered Architecture Transaction Script Worked …. for a while

  53. vladikk Customer Events Event Crunchers Marketing CRM Analysis Flag Flag

    Calculated fields
  54. vladikk

  55. vladikk Marketing CRM Analysis Customer Events Event Crunchers

  56. vladikk Customer Events Event Crunchers (BBOM) CRM Marketing Analysis

  57. vladikk Customer Events Event Crunchers (Event Sourced) CRM Marketing Analysis

  58. vladikk THE BONUSES BOUNDED CONTEXT 04

  59. vladikk Sales Commissions Reports

  60. vladikk Competitive advantage? - No Off-the-shelve solution? - No =>

    Supporting sub-domain
  61. vladikk Active Record Service / Application Layer Presentation Infrastructure

  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!
  63. vladikk Active Record Service / Application Layer Presentation Infrastructure BIG

    BALL OF MUD
  64. vladikk Event Sourced Domain Model Service / Application Layer Presentation

    Infrastructure BIG BALL OF MUD
  65. vladikk Active Record Service / Application Layer Presentation Infrastructure Transaction

    Script Service / Application Layer Presentation Infrastructure Event Crunchers Bonuses Ubiquitous Language
  66. vladikk Ubiquitous Language Core Bounded Contexts Protect by
 decomposing to

    Identify Domains Domain Model Supporting Generic AR / TS Adopt Implement as
  67. vladikk THE MARKETING HUB BOUNDED CONTEXT 05

  68. vladikk Leads Marketing Hub Client Client Client

  69. vladikk Competitive advantage? - Yes => Core Domain

  70. vladikk Event Sourced Domain Model CQRS Microservices

  71. vladikk Micro
 Service Micro
 Service Micro
 Service Micro
 Service

  72. vladikk Aggregate Aggregate Aggregate Aggregate

  73. vladikk Aggregate Aggregate Aggregate Aggregate Event Sourced
 Aggregate

  74. vladikk Aggregate Aggregate Aggregate Aggregate Event Sourced
 Aggregate

  75. vladikk Event Sourced Domain Model CQRS Microservices

  76. vladikk Aggregate Aggregate Aggregate Aggregate Event Sourced
 Aggregate

  77. vladikk TECHNICAL COMPLEXITY BUSINESS COMPLEXITY >

  78. vladikk Aggregate Aggregate Aggregate Aggregate Event Sourced
 Aggregate

  79. Marketing Bonuses U D CRM U D Marketing
 Hub U

    U D D Event Crunchers U D U D
  80. WHAT
 WE HAVE L E A R N E D

  81. vladikk UBIQUITOUS LANGUAGE 01

  82. vladikk UBIQUITOUS LANGUAGE THE CORE DOMAIN OF DOMAIN-DRIVEN DESIGN

  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
  84. vladikk Invest in the Ubiquitous Language early on

  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
  86. vladikk Cheap!

  87. vladikk DOMAIN TYPES 02

  88. vladikk Core Supporting Generic

  89. vladikk Generic Domain Adopt / Buy Supporting Domain Active Record

    / Transaction Script Core Domain Domain Model / Event Sourcing
  90. vladikk COMPANIES CHANGE, EVOLVE, REINVENT THEMSELVES DOMAINS' TYPES CHANGE ACCORDINGLY

  91. vladikk SUPPORTING ➤ CORE • Event Crunchers • Bonuses SUPPORTING

    ➤ GENERIC • Creative Catalog CORE ➤ GENERIC • Lead Evaluation System CORE ➤ SUPPORTING • Marketing Hub GENERIC ➤ CORE • AWS
  92. vladikk Generic Domain Adopt / Buy Supporting Domain Active Record

    / Transaction Script Core Domain Domain Model / Event Sourcing
  93. vladikk Generic Domain Adopt / Buy Supporting Domain Active Record

    / Transaction Script Core Domain Domain Model / Event Sourcing
  94. vladikk Less waste Dialog with the business IMPLEMENTATION DESIGN ➤

    DOMAIN TYPE
  95. vladikk • Questionable competitive edge? • Accidental “business” complexity? •

    Unexpected competitive edge? BUSINESS COMPLEXITY ≠ DOMAIN TYPE?
  96. vladikk Generic Domain Adopt / Buy Supporting Domain Active Record

    / Transaction Script Core Domain Domain Model / Event Sourcing IMPLEMENTATION DESIGN ➤ DOMAIN TYPE
  97. vladikk IMPLEMENTATION STRATEGIES 03

  98. vladikk How to Model the Business Logic?

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

    Active Record (PoEAA) Domain Model (PoEAA + DDD) Event Sourced Domain Model
  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
  101. vladikk MAPPING ARCHITECTURAL PATTERNS Event Sourced Domain Model ➤ CQRS

    Domain Model ➤ Hexagonal Architecture Active Record ➤ Layered Architecture Transaction Script ➤ “Keep it simple” Architecture
  102. vladikk MAPPING ARCHITECTURAL PATTERNS Event Sourced Domain Model ➤ CQRS

    Domain Model ➤ Hexagonal Architecture Active Record ➤ Layered Architecture Transaction Script ➤ “Keep it simple” Architecture
  103. vladikk Transaction Script Active Record Domain Model Event Sourced Domain

    Model
  104. vladikk PAIN? BUSINESS CHANGED? DOMAIN TYPE CHANGED? REVISE IMPLEMENTATION STRATEGY?

  105. vladikk Transaction Script Active Record Domain Model Event Sourced Domain

    Model
  106. vladikk CQRS 04

  107. vladikk Event Sourcing ➤ CQRS

  108. vladikk EVENT SOURCING BUSINESS DOMAIN MODELING PATTERN CQRS ARCHITECTURAL PATTERN

    FOR REPRESENTING DATA IN DIFFERENT PERSISTENT MODELS
  109. vladikk Transaction Script Active Record Domain Model } Can benefit

    from CQRS and State-Based Projections
  110. vladikk RDBMS Search index Files
 storage Projection
 Engine Projected
 Model

    Projected
 Model Changes Application Query Query Commit
  111. vladikk COMMAND QUERY 
 RESPONSIBILITY SEGREGATION?

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

    What are the outcomes? } Can be delivered asynchronously through queries … but why?
  113. vladikk Write
 Model Projection Projection Projection
 Engine Projected
 Model Projected


    Model Changes Application Client Command
 Execution Result Query
  114. vladikk 05 BOUNDED CONTEXTS

  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
  116. vladikk Bonuses Event Crunchers DOMAIN-BASED BOUNDARIES

  117. vladikk AGGREGATE-BASED BOUNDARIES Aggregate Aggregate Aggregate Aggregate

  118. vladikk L e a d SUICIDAL BOUNDARIES

  119. vladikk

  120. vladikk BOUNDED CONTEXTS ARE NOT MICROSERVICES

  121. vladikk BOUNDED CONTEXTS PROTECT INTEGRITY OF A UBIQUITOUS LANGUAGE

  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
  123. vladikk MICROSERVICES DECOMPOSITION OF A SYSTEM INTO LOOSELY COUPLED COMPONENTS

    BOUNDED CONTEXTS PROTECT INTEGRITY OF A UBIQUITOUS LANGUAGE
  124. vladikk Micro
 Service Micro
 Service Micro
 Service Micro
 Service

  125. Finding service boundaries is really damn hard… There is no

    flowchart! “ Udi Dahan
  126. vladikk THERE ARE GOING TO BE MISTAKES ACCEPT IT AND

    DON’T MAKE FATAL ONES
  127. vladikk THE LESS YOU KNOW ABOUT THE DOMAIN THE WIDER

    THE INITIAL BOUNDARIES START WITH BIGGER BOUNDARIES DECOMPOSE LATER, AS YOU GAIN KNOWLEDGE
  128. vladikk Aggregate Aggregate Aggregate Aggregate Event Sourced
 Aggregate

  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
  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
  131. vladikk START WITH BIGGER BOUNDARIES DECOMPOSE AS YOU GAIN DOMAIN

    KNOWLEDGE
  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
  133. vladikk SUMMARY

  134. vladikk Ubiquitous Language Bounded Contexts Protect by
 decomposing to Design


    Implementation Core Supporting Generic Domain Model AR / TS Adopt Confirm w/
 Business
  135. vladikk Ubiquitous Language Bounded Contexts Protect by
 decomposing to Design


    Implementation Core Supporting Generic Domain Model AR / TS Adopt Confirm w/
 Business
  136. vladikk Ubiquitous Language Bounded Contexts Protect by
 decomposing to Design


    Implementation Core Supporting Generic Domain Model AR / TS Adopt Confirm w/
 Business
  137. vladikk Ubiquitous Language Bounded Contexts Protect by
 decomposing to Design


    Implementation Core Supporting Generic Domain Model AR / TS Adopt Confirm w/
 Business
  138. vladikk Ubiquitous Language Bounded Contexts Protect by
 decomposing to Design


    Implementation Core Supporting Generic Domain Model AR / TS Adopt Confirm w/
 Business
  139. vladikk Creative Agency Advertiser Publisher Website Placement Ad Zone Ad

    Type Target Market Group Zone Type Funnel Contract Budget Unit Campaign Aggregates everywhere!!!
  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!!!
  141. vladikk P.S.

  142. vladikk

  143. THANK YOU! @vladikk vladikk.com