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

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.

Vladik Khononov

October 30, 2018
Tweet

More Decks by Vladik Khononov

Other Decks in Programming

Transcript

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

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

    Ad Zone Ad Type Target Market Group Zone Type Funnel Contract Budget Unit Audience
  3. 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
  4. 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
  5. 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
  6. vladikk Aggregates will:
 • Protect transactional boundaries
 • Encompass business

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

    logic and invariants Domain Service / Application Layer Presentation Infrastructure Domain Service / Application Layer
  8. 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!
  9. vladikk Active Record Service / Application Layer Presentation Infrastructure Transaction

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

    Identify Domains Domain Model Supporting Generic AR / TS Adopt Implement as
  11. Marketing Bonuses U D CRM U D Marketing
 Hub U

    U D D Event Crunchers U D U D
  12. 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
  13. 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
  14. vladikk Generic Domain Adopt / Buy Supporting Domain Active Record

    / Transaction Script Core Domain Domain Model / Event Sourcing
  15. vladikk SUPPORTING ➤ CORE • Event Crunchers • Bonuses SUPPORTING

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

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

    / Transaction Script Core Domain Domain Model / Event Sourcing
  18. vladikk • Questionable competitive edge? • Accidental “business” complexity? •

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

    / Transaction Script Core Domain Domain Model / Event Sourcing IMPLEMENTATION DESIGN ➤ DOMAIN TYPE
  20. vladikk How to Model the Business Logic? Transaction Script (PoEAA)

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

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

    Domain Model ➤ Hexagonal Architecture Active Record ➤ Layered Architecture Transaction Script ➤ “Keep it simple” Architecture
  24. vladikk EVENT SOURCING BUSINESS DOMAIN MODELING PATTERN CQRS ARCHITECTURAL PATTERN

    FOR REPRESENTING DATA IN DIFFERENT PERSISTENT MODELS
  25. vladikk RDBMS Search index Files
 storage Projection
 Engine Projected
 Model

    Projected
 Model Changes Application Query Query Commit
  26. vladikk Did command succeed or fail? If failed - why?

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


    Model Changes Application Client Command
 Execution Result Query
  28. 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
  29. 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
  30. vladikk MICROSERVICES DECOMPOSITION OF A SYSTEM INTO LOOSELY COUPLED COMPONENTS

    BOUNDED CONTEXTS PROTECT INTEGRITY OF A UBIQUITOUS LANGUAGE
  31. vladikk THE LESS YOU KNOW ABOUT THE DOMAIN THE WIDER

    THE INITIAL BOUNDARIES START WITH BIGGER BOUNDARIES DECOMPOSE LATER, AS YOU GAIN KNOWLEDGE
  32. 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
  33. 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
  34. 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
  35. vladikk Ubiquitous Language Bounded Contexts Protect by
 decomposing to Design


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


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


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


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


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

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