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

7 Years of DDD: Tackling Complexity in Marketing Systems

7 Years of DDD: Tackling Complexity in Marketing Systems

Turns out Domain-Driven Design works not only for cargo shipping, but for marketing systems as well. In this session I’d like to share the story of Plexop - a large-scale marketing system that spans over a dozen of different business domains: from optimizing advertising spaces, to managing sales agents’ commissions. Plexop had to be implemented with tight resources, and even tighter time to market. That’s why we embraced Domain-Driven Design from day one, and boy did it pay out. I’ll show how DDD allowed us deliver Plexop on time and on budget: what worked, what didn’t, what we had to learn ourselves, and the prices we paid when tried to cut corners.

B90ab53ba7cf16ed1a4bb679cc6751d7?s=128

Vladik Khononov

February 01, 2018
Tweet

Transcript

  1. 7 YEARS OF DDD: TACKLING COMPLEXITY
 IN LARGE SCALE MARKETING

    SYSTEMS
  2. Vladik Khononov IAF Malam Team MSN-IL Cellcom Internovus Twitter: @vladikk


    
 Blog: vladikk.com
  3. Vladik Khononov IAF Malam Team MSN-IL Cellcom Internovus Twitter: @vladikk


    
 Blog: vladikk.com
  4. AGENDA

  5. PART 1
 5 BOUNDED CONTEXTS PART 2 PRACTICAL ADVICE

  6. None
  7. YAY!!!

  8. Your Product Marketing
 Strategy Creatives Campaigns Sales
 Agents Optimization Profits

  9. THE FIRST BOUNDED CONTEXT 01

  10. VER 1.0 Media Buying Creatives Catalog Campaign Management

  11. None
  12. None
  13. Very nice!

  14. Aggregates everywhere!!!

  15. Aggregates everywhere!!! Creative Agency Advertiser Publisher Website Placement Ad Zone

    Ad Type Target Market Group Zone Type Funnel Contract Budget Unit Campaign
  16. The Bounded Context Creative Agency Advertiser Publisher Website Placement Ad

    Zone Ad Type Target Market Group Zone Type Funnel Contract Budget Unit Audience
  17. Domain Model Service / Application Layer Presentation Infrastructure Anemic! Behaviour

  18. Imperfect architecture “QA is for cowards” BUT IT WORKED!

  19. UBIQUITOUS LANGUAGE

  20. Domain Expert Software Developer Has no experience in online marketing

    Nice people!
  21. Smooth communication Strong grasp of the business domain Working software

    Aggressive time to market
  22. Ubiquitous Language Anemic Domain Model

  23. Leads Sales Agents Ads

  24. Leads CRM Categorize Desk Desk Desk Sales Agents Sales Agents

    Sales Agents Clients’ Systems
  25. None
  26. Lead qualification Agent qualification Agents’ commissions

  27. THE CRM BOUNDED CONTEXT 02

  28. Ubiquitous Language Anemic Domain Model

  29. 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
  30. Domain Expert Software Developer …. Lead …. …. Campaign…

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

  34. 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
  35. 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
  36. Aggregates will:
 • Protect transactional boundaries
 • Encompass business logic

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

    and invariants Domain Service / Application Layer Presentation Infrastructure Domain Service / Application Layer
  38. None
  39. None
  40. None
  41. Stored procedures???

  42. Group Desk Qualification Assessment Organization Unit Assignment Rank Message On-site

    Activity Brand Lead Campaign Lead
  43. L e a d CRM Team DBA Team

  44. None
  45. Inconsistent models No shared understanding Duplication of knowledge Went out

    of sync quickly NIGHTMARE
  46. Wasn’t delivered on time Production issues Data corruption Thrown away

    and reimplemented
  47. Ubiquitous Language Domain Model Bounded Contexts Protect w/ Implement as

  48. Ubiquitous Language Domain Model Bounded Contexts Protect w/ Implement as

    …Dude, where are Sub-Domains?
  49. Not all of a large system will be well designed

    “ Eric Evans
  50. THE CRUNCHERS BOUNDED CONTEXT 03

  51. Marketing CRM Analysis Customer Events Marketing CRM

  52. Marketing CRM Analysis Customer Events Event Crunchers

  53. Competitive advantage? - No Off-the-shelve solution? - No => Supporting

    sub-domain
  54. Layered Architecture Transaction Script Worked …. for a while

  55. Customer Events Event Crunchers Marketing CRM Analysis Flag Flag Calculated

    fields
  56. None
  57. Marketing CRM Analysis Customer Events Event Crunchers

  58. Customer Events Event Crunchers (BBOM) CRM Marketing Analysis

  59. Customer Events Event Crunchers (Event Sourced) CRM Marketing Analysis

  60. THE BONUSES BOUNDED CONTEXT 04

  61. Sales Commissions Reports

  62. Competitive advantage? - No Off-the-shelve solution? - No => Supporting

    sub-domain
  63. Active Record Service / Application Layer Presentation Infrastructure

  64. 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!
  65. Active Record Service / Application Layer Presentation Infrastructure BIG BALL

    OF MUD
  66. Active Record Service / Application Layer Presentation Infrastructure Transaction Script

    Service / Application Layer Presentation Infrastructure Event Crunchers Bonuses
  67. Active Record Service / Application Layer Presentation Infrastructure Transaction Script

    Service / Application Layer Presentation Infrastructure Event Crunchers Bonuses Ubiquitous Language
  68. Event Sourced Domain Model Service / Application Layer Presentation Infrastructure

    Event Sourced Domain Model Service / Application Layer Presentation Infrastructure Event Crunchers Bonuses Ubiquitous Language
  69. Ubiquitous Language Core Bounded Contexts Protect by
 decomposing to Identify

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

  71. Leads Marketing Hub Client Client Client

  72. Competitive advantage? - Yes => Core Domain

  73. Event Sourced Domain Model CQRS Microservices

  74. Micro
 Service Micro
 Service Micro
 Service Micro
 Service

  75. Aggregate Aggregate Aggregate Aggregate

  76. Aggregate Aggregate Aggregate Aggregate Event Sourced
 Aggregate

  77. Aggregate Aggregate Aggregate Aggregate Event Sourced
 Aggregate

  78. Event Sourced Domain Model CQRS Microservices

  79. Aggregate Aggregate Aggregate Aggregate Event Sourced
 Aggregate

  80. TECHNICAL COMPLEXITY BUSINESS COMPLEXITY >

  81. Aggregate Aggregate Aggregate Aggregate Event Sourced
 Aggregate

  82. Marketing Bonuses U D CRM U D Marketing
 Hub U

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

  84. UBIQUITOUS LANGUAGE 01

  85. Ubiquitous Language: The Core Domain of Domain-Driven Design

  86. UBIQUITOUS LANGUAGE DOCUMENTS TESTS JIRA >

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

  89. Cheap!

  90. You don’t need a budget for a Ubiquitous Language

  91. DOMAIN TYPES 02

  92. Core Supporting Generic

  93. Generic Domain Adopt / Buy Supporting Domain Active Record /

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

  95. SUPPORTING ➤ CORE • Event Crunchers • Bonuses SUPPORTING ➤

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

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

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

    TYPE
  99. • Questionable competitive edge? • Accidental “business” complexity? • Unexpected

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

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

  102. How to Model the Business Logic? Transaction Script Active Record

    Domain Model Event Sourced Domain Model
  103. 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
  104. MAPPING ARCHITECTURAL PATTERNS Event Sourced Domain Model ➤ CQRS Domain

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

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

  107. PAIN? BUSINESS CHANGED? DOMAIN TYPE CHANGED? REVISE IMPLEMENTATION STRATEGY? ➤

  108. Transaction Script Active Record Domain Model Event Sourced Domain Model

  109. CQRS 04

  110. Event Sourcing ➤ CQRS

  111. EVENT SOURCING A WAY OF MODELING BUSINESS DOMAINS CQRS ARCHITECTURAL

    PATTERN FOR REPRESENTING THE SAME DATA IN DIFFERENT MODELS
  112. Transaction Script Active Record Domain Model } Can benefit from

    CQRS and State-Based Projections
  113. 05 BOUNDED CONTEXTS

  114. 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
  115. Bonuses Event Crunchers DOMAIN-BASED BOUNDARIES

  116. AGGREGATE-BASED BOUNDARIES Aggregate Aggregate Aggregate Aggregate

  117. L e a d SUICIDAL BOUNDARIES

  118. None
  119. Finding service boundaries is really damn hard… There is no

    flowchart! “ Udi Dahan
  120. THERE ARE GOING TO BE MISTAKES ACCEPT IT, AND DON’T

    MAKE FATAL ONES
  121. START WITH BIGGER BOUNDARIES DECOMPOSE LATER, AS YOU GAIN KNOWLEDGE

  122. THE LESS YOU KNOW ABOUT THE DOMAIN - THE WIDER

    THE INITIAL BOUNDARIES ARE
  123. Aggregate Aggregate Aggregate Aggregate Event Sourced
 Aggregate

  124. Marketing Creative Agency Publisher Website Advertiser Ad Zone Ad Type

    Target Market Group Zone Type Funnel Contract Budget Unit Audience Placement Visit Lead Campaign
  125. 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
  126. START WITH BIGGER BOUNDARIES DECOMPOSE AS YOU GAIN DOMAIN KNOWLEDGE

  127. 1. Ubiquitous Language is not optional 2. Domain Types change.

    Embrace these changes 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. Start with bigger boundaries, and divide as you gain domain knowledge
  128. 07 SUMMARY

  129. Ubiquitous Language Bounded Contexts Protect by
 decomposing to Design
 Implementation

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

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

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

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

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

    Target Market Group Zone Type Funnel Contract Budget Unit Campaign Aggregates everywhere!!!
  135. Ubiquitous Language Bounded Contexts Protect by
 decomposing to Design
 Implementation

    Core Supporting Generic Domain Model AR / TS Adopt Confirm w/
 Business Ubiquitous Language Everywhere!!!
  136. P.S.

  137. None
  138. QUESTIONS?

  139. THANK YOU! @vladikk http://vladikk.com