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. 4.
  2. 6.
  3. 7.
  4. 11.
  5. 12.
  6. 15.

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

    Ad Type Target Market Group Zone Type Funnel Contract Budget Unit Campaign
  7. 16.

    The Bounded Context Creative Agency Advertiser Publisher Website Placement Ad

    Zone Ad Type Target Market Group Zone Type Funnel Contract Budget Unit Audience
  8. 25.
  9. 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
  10. 31.
  11. 32.
  12. 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
  13. 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
  14. 36.

    Aggregates will:
 • Protect transactional boundaries
 • Encompass business logic

    and invariants Domain Service / Application Layer Presentation Infrastructure
  15. 37.

    Aggregates will:
 • Protect transactional boundaries
 • Encompass business logic

    and invariants Domain Service / Application Layer Presentation Infrastructure Domain Service / Application Layer
  16. 38.
  17. 39.
  18. 40.
  19. 44.
  20. 56.
  21. 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!
  22. 66.

    Active Record Service / Application Layer Presentation Infrastructure Transaction Script

    Service / Application Layer Presentation Infrastructure Event Crunchers Bonuses
  23. 67.

    Active Record Service / Application Layer Presentation Infrastructure Transaction Script

    Service / Application Layer Presentation Infrastructure Event Crunchers Bonuses Ubiquitous Language
  24. 68.

    Event Sourced Domain Model Service / Application Layer Presentation Infrastructure

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

    Ubiquitous Language Core Bounded Contexts Protect by
 decomposing to Identify

    Domains Domain Model Supporting Generic AR / TS Adopt Implement as
  26. 82.

    Marketing Bonuses U D CRM U D Marketing
 Hub U

    U D D Event Crunchers U D U D
  27. 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
  28. 89.
  29. 93.

    Generic Domain Adopt / Buy Supporting Domain Active Record /

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

    SUPPORTING ➤ CORE • Event Crunchers • Bonuses SUPPORTING ➤

    GENERIC • Creative Catalog CORE ➤ GENERIC • Lead Evaluation System CORE ➤ SUPPORTING • Marketing Hub GENERIC ➤ CORE • AWS
  31. 96.

    Generic Domain Adopt / Buy Supporting Domain Active Record /

    Transaction Script Core Domain Domain Model / Event Sourcing
  32. 97.

    Generic Domain Adopt / Buy Supporting Domain Active Record /

    Transaction Script Core Domain Domain Model / Event Sourcing
  33. 99.
  34. 100.

    Generic Domain Adopt / Buy Supporting Domain Active Record /

    Transaction Script Core Domain Domain Model / Event Sourcing IMPLEMENTATION DESIGN ➤ DOMAIN TYPE
  35. 102.
  36. 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
  37. 104.

    MAPPING ARCHITECTURAL PATTERNS Event Sourced Domain Model ➤ CQRS Domain

    Model ➤ Hexagonal Architecture Active Record ➤ Layered Architecture Transaction Script ➤ “Keep it simple” Architecture
  38. 105.

    MAPPING ARCHITECTURAL PATTERNS Event Sourced Domain Model ➤ CQRS Domain

    Model ➤ Hexagonal Architecture Active Record ➤ Layered Architecture Transaction Script ➤ “Keep it simple” Architecture
  39. 109.
  40. 111.

    EVENT SOURCING A WAY OF MODELING BUSINESS DOMAINS CQRS ARCHITECTURAL

    PATTERN FOR REPRESENTING THE SAME DATA IN DIFFERENT MODELS
  41. 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
  42. 118.
  43. 122.
  44. 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
  45. 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
  46. 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
  47. 128.
  48. 129.

    Ubiquitous Language Bounded Contexts Protect by
 decomposing to Design
 Implementation

    Core Supporting Generic Domain Model AR / TS Adopt Confirm w/
 Business
  49. 130.

    Ubiquitous Language Bounded Contexts Protect by
 decomposing to Design
 Implementation

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

    Ubiquitous Language Bounded Contexts Protect by
 decomposing to Design
 Implementation

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

    Ubiquitous Language Bounded Contexts Protect by
 decomposing to Design
 Implementation

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

    Ubiquitous Language Bounded Contexts Protect by
 decomposing to Design
 Implementation

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

    Creative Agency Advertiser Publisher Website Placement Ad Zone Ad Type

    Target Market Group Zone Type Funnel Contract Budget Unit Campaign Aggregates everywhere!!!
  54. 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!!!
  55. 136.
  56. 137.
  57. 138.