SLIDE 1 vladikk
7 YEARS OF DDD
Tackling Complexity in
Large Scale Marketing Systems
SLIDE 3 @vladikk vladikk.com Internovus
SLIDE 4 vladikk
PART 2
5 PRACTICAL ADVICES
PART 1
5 BOUNDED CONTEXTS
SLIDE 5
SLIDE 6 vladikk
Your Product Marketing
Strategy Creatives Campaigns Sales
Agents Optimization Profits
SLIDE 7 vladikk
THE FIRST BOUNDED CONTEXT
01
SLIDE 8 vladikk
Media Buying Creatives Catalog Campaign Management
VER 1.0
SLIDE 9 vladikk
🤕
SLIDE 10 vladikk
SLIDE 12 vladikk
Aggregates everywhere!!!
SLIDE 13 vladikk
Aggregates everywhere!!!
Creative Agency Advertiser
Publisher
Website Placement Ad Zone Ad Type
Target Market
Group Zone Type Funnel Contract Budget Unit
Campaign
SLIDE 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
SLIDE 15 vladikk
Domain Model Service / Application Layer Presentation Infrastructure Anemic! Behaviour
SLIDE 16 vladikk
Imperfect architecture “QA is for cowards”
BUT IT WORKED!
SLIDE 17 vladikk
UBIQUITOUS LANGUAGE
SLIDE 18 vladikk
Domain Experts Software Developers No experience in online marketing Nice people!
SLIDE 19 vladikk
Smooth communication Strong grasp of the business domain Working software Aggressive time to market
SLIDE 20 vladikk
Ubiquitous Language Anemic Domain Model
SLIDE 21 vladikk
Leads Sales Agents Ads
SLIDE 22 vladikk
Leads CRM Categorize Desk Desk Desk Sales Agents Sales Agents Sales Agents
SLIDE 23 Leads CRM Categorize Desk Desk Desk Sales Agents Sales Agents Sales Agents Clients’ Systems
SLIDE 24 vladikk
SLIDE 25 vladikk
Lead qualification Agent qualification Agents’ commissions
SLIDE 26 vladikk
THE CRM BOUNDED CONTEXT
02
SLIDE 27 vladikk
Ubiquitous Language Anemic Domain Model
SLIDE 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
SLIDE 29 vladikk
Domain Experts Software Developers …. Lead …. …. Campaign…
SLIDE 30 vladikk
SLIDE 31
SLIDE 32 vladikk
BOUNDED CONTEXTS PROTECT THE LANGUAGE AGGREGATES PROTECT CONSISTENCY OF DATA
SLIDE 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
SLIDE 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
SLIDE 35 vladikk
Aggregates will:
- Protect transactional boundaries
- Encompass business logic and invariants
Domain Service / Application Layer Presentation Infrastructure
SLIDE 36 vladikk
Aggregates will:
- Protect transactional boundaries
- Encompass business logic and invariants
Domain Service / Application Layer Presentation Infrastructure Domain Service / Application Layer
SLIDE 37
SLIDE 38 vladikk
SLIDE 39
SLIDE 40 vladikk
Stored procedures???
SLIDE 41 vladikk
Group Desk Qualification Assessment Organization Unit Assignment Rank Message On-site Activity Brand Lead Campaign Lead
SLIDE 42 L e a d
CRM Team
DBA Team
SLIDE 43
SLIDE 44 vladikk
Inconsistent models No shared understanding Duplication of knowledge Went out of sync quickly NIGHTMARE
SLIDE 45 vladikk
Wasn’t delivered on time Production issues Data corruption Thrown away and reimplemented
SLIDE 46 vladikk
Ubiquitous Language Domain Model Bounded Contexts
Protect w/ Implement as
SLIDE 47 Not all of a large system will be well designed
“
Eric Evans
SLIDE 48 vladikk
THE CRUNCHERS BOUNDED CONTEXT
03
SLIDE 49 vladikk
Marketing CRM Analysis Customer Events Marketing CRM
SLIDE 50 vladikk
Marketing CRM Analysis Customer Events Event Crunchers
SLIDE 51 vladikk
Competitive advantage? - No Off-the-shelve solution? - No => Supporting sub-domain
SLIDE 52 vladikk
Layered Architecture Transaction Script Worked …. for a while
SLIDE 53 vladikk
Customer Events Event Crunchers Marketing CRM Analysis Flag Flag Calculated fields
SLIDE 54 vladikk
SLIDE 55 vladikk
Marketing CRM Analysis Customer Events Event Crunchers
SLIDE 56 vladikk
Customer Events Event Crunchers (BBOM) CRM Marketing Analysis
SLIDE 57 vladikk
Customer Events Event Crunchers
(Event Sourced)
CRM Marketing Analysis
SLIDE 58 vladikk
THE BONUSES BOUNDED CONTEXT
04
SLIDE 59 vladikk
Sales Commissions Reports
SLIDE 60 vladikk
Competitive advantage? - No Off-the-shelve solution? - No => Supporting sub-domain
SLIDE 61 vladikk
Active Record Service / Application Layer Presentation Infrastructure
SLIDE 62 vladikk
Sales Commissions Reports Let’s try different percentages What if the percentage could be a function
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!
SLIDE 63 vladikk
Active Record Service / Application Layer Presentation Infrastructure BIG BALL OF MUD
SLIDE 64 vladikk
Event Sourced Domain Model Service / Application Layer Presentation Infrastructure BIG BALL OF MUD
SLIDE 65 vladikk
Active Record Service / Application Layer Presentation Infrastructure Transaction Script Service / Application Layer Presentation Infrastructure Event Crunchers Bonuses Ubiquitous Language
SLIDE 66 vladikk
Ubiquitous Language Core Bounded Contexts
Protect by
decomposing to Identify Domains
Domain Model Supporting Generic AR / TS Adopt
Implement as
SLIDE 67 vladikk
THE MARKETING HUB BOUNDED CONTEXT
05
SLIDE 68 vladikk
Leads Marketing Hub Client Client Client
SLIDE 69 vladikk
Competitive advantage? - Yes => Core Domain
SLIDE 70 vladikk
Event Sourced Domain Model CQRS Microservices
SLIDE 71 vladikk
Micro
Service Micro
Service Micro
Service Micro
Service
SLIDE 72 vladikk
Aggregate Aggregate Aggregate Aggregate
SLIDE 73 vladikk
Aggregate Aggregate Aggregate Aggregate Event Sourced
Aggregate
SLIDE 74 vladikk
Aggregate Aggregate Aggregate Aggregate Event Sourced
Aggregate
SLIDE 75 vladikk
Event Sourced Domain Model CQRS Microservices
SLIDE 76 vladikk
Aggregate Aggregate Aggregate Aggregate Event Sourced
Aggregate
SLIDE 77 vladikk
TECHNICAL COMPLEXITY BUSINESS COMPLEXITY
>
SLIDE 78 vladikk
Aggregate Aggregate Aggregate Aggregate Event Sourced
Aggregate
SLIDE 79 Marketing Bonuses U D CRM U D Marketing
Hub U U D D Event Crunchers U D U D
SLIDE 80 WHAT
WE HAVE L E A R N E D
SLIDE 81 vladikk
UBIQUITOUS
LANGUAGE
01
SLIDE 82 vladikk
UBIQUITOUS LANGUAGE
THE CORE DOMAIN OF DOMAIN-DRIVEN DESIGN
SLIDE 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
SLIDE 84 vladikk
Invest in the Ubiquitous Language early on
SLIDE 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
SLIDE 87 vladikk
DOMAIN
TYPES
02
SLIDE 88 vladikk
Core Supporting Generic
SLIDE 89 vladikk
Generic Domain Adopt / Buy Supporting Domain Active Record / Transaction Script Core Domain Domain Model / Event Sourcing
SLIDE 90 vladikk
COMPANIES CHANGE, EVOLVE, REINVENT THEMSELVES
DOMAINS' TYPES CHANGE ACCORDINGLY
SLIDE 91 vladikk
SUPPORTING ➤ CORE
SUPPORTING ➤ GENERIC
CORE ➤ GENERIC
CORE ➤ SUPPORTING
GENERIC ➤ CORE
SLIDE 92 vladikk
Generic Domain Adopt / Buy Supporting Domain Active Record / Transaction Script Core Domain Domain Model / Event Sourcing
SLIDE 93 vladikk
Generic Domain Adopt / Buy Supporting Domain Active Record / Transaction Script Core Domain Domain Model / Event Sourcing
SLIDE 94 vladikk
Less waste Dialog with the business
IMPLEMENTATION DESIGN ➤ DOMAIN TYPE
SLIDE 95 vladikk
- Questionable competitive edge?
- Accidental “business” complexity?
- Unexpected competitive edge?
BUSINESS COMPLEXITY ≠ DOMAIN TYPE?
SLIDE 96 vladikk
Generic Domain Adopt / Buy Supporting Domain Active Record / Transaction Script Core Domain Domain Model / Event Sourcing
IMPLEMENTATION DESIGN ➤ DOMAIN TYPE
SLIDE 97 vladikk
IMPLEMENTATION
STRATEGIES
03
SLIDE 98 vladikk
How to Model the Business Logic?
SLIDE 99 vladikk
How to Model the Business Logic?
Transaction Script (PoEAA) Active Record (PoEAA) Domain Model (PoEAA + DDD) Event Sourced Domain Model
SLIDE 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
SLIDE 101 vladikk
MAPPING ARCHITECTURAL PATTERNS
Event Sourced Domain Model ➤ CQRS Domain Model ➤ Hexagonal Architecture Active Record ➤ Layered Architecture Transaction Script ➤ “Keep it simple” Architecture
SLIDE 102 vladikk
MAPPING ARCHITECTURAL PATTERNS
Event Sourced Domain Model ➤ CQRS Domain Model ➤ Hexagonal Architecture Active Record ➤ Layered Architecture Transaction Script ➤ “Keep it simple” Architecture
SLIDE 103 vladikk
Transaction Script Active Record Domain Model Event Sourced Domain Model
SLIDE 104 vladikk
PAIN?
BUSINESS CHANGED? DOMAIN TYPE CHANGED? REVISE IMPLEMENTATION STRATEGY?
➤
SLIDE 105 vladikk
Transaction Script Active Record Domain Model Event Sourced Domain Model
SLIDE 106 vladikk
CQRS
04
SLIDE 107 vladikk
Event Sourcing ➤ CQRS
SLIDE 108 vladikk
EVENT SOURCING BUSINESS DOMAIN MODELING PATTERN CQRS ARCHITECTURAL PATTERN FOR REPRESENTING DATA IN DIFFERENT PERSISTENT MODELS
SLIDE 109 vladikk
Transaction Script Active Record Domain Model } Can benefit from CQRS and State-Based Projections
SLIDE 110 vladikk
RDBMS Search index Files
storage
Projection
Engine
Projected
Model Projected
Model Changes
Application
Query Query Commit
SLIDE 111 vladikk
COMMAND QUERY
RESPONSIBILITY SEGREGATION?
SLIDE 112 vladikk
Did command succeed or fail? If failed - why? What are the outcomes? }
Can be delivered asynchronously through queries … but why?
SLIDE 113 vladikk
Write
Model Projection Projection
Projection
Engine
Projected
Model Projected
Model Changes
Application Client
Command
Execution Result Query
SLIDE 114 vladikk
05
BOUNDED
CONTEXTS
SLIDE 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
SLIDE 116 vladikk
Bonuses Event Crunchers
DOMAIN-BASED BOUNDARIES
SLIDE 117 vladikk
AGGREGATE-BASED BOUNDARIES
Aggregate Aggregate Aggregate Aggregate
SLIDE 118 vladikk
L e a d
SUICIDAL BOUNDARIES
SLIDE 119 vladikk
SLIDE 120 vladikk
BOUNDED CONTEXTS ARE NOT MICROSERVICES
SLIDE 121 vladikk
BOUNDED CONTEXTS PROTECT INTEGRITY OF A UBIQUITOUS LANGUAGE
SLIDE 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
SLIDE 123 vladikk
MICROSERVICES DECOMPOSITION OF A SYSTEM INTO LOOSELY COUPLED COMPONENTS BOUNDED CONTEXTS PROTECT INTEGRITY OF A UBIQUITOUS LANGUAGE
SLIDE 124 vladikk
Micro
Service Micro
Service Micro
Service Micro
Service
SLIDE 125 Finding service boundaries is really damn hard… There is no flowchart!
“
Udi Dahan
SLIDE 126 vladikk
THERE ARE GOING TO BE MISTAKES ACCEPT IT AND DON’T MAKE FATAL ONES
SLIDE 127 vladikk
THE LESS YOU KNOW ABOUT THE DOMAIN THE WIDER THE INITIAL BOUNDARIES START WITH BIGGER BOUNDARIES DECOMPOSE LATER, AS YOU GAIN KNOWLEDGE
SLIDE 128 vladikk
Aggregate Aggregate Aggregate Aggregate Event Sourced
Aggregate
SLIDE 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
SLIDE 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
SLIDE 131 vladikk
START WITH BIGGER BOUNDARIES DECOMPOSE AS YOU GAIN DOMAIN KNOWLEDGE
SLIDE 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
SLIDE 133 vladikk
SUMMARY
SLIDE 134 vladikk
Ubiquitous Language Bounded Contexts
Protect by
decomposing to Design
Implementation
Core Supporting Generic Domain Model AR / TS Adopt
Confirm w/
Business
SLIDE 135 vladikk
Ubiquitous Language Bounded Contexts
Protect by
decomposing to Design
Implementation
Core Supporting Generic Domain Model AR / TS Adopt
Confirm w/
Business
SLIDE 136 vladikk
Ubiquitous Language Bounded Contexts
Protect by
decomposing to Design
Implementation
Core Supporting Generic Domain Model AR / TS Adopt
Confirm w/
Business
SLIDE 137 vladikk
Ubiquitous Language Bounded Contexts
Protect by
decomposing to Design
Implementation
Core Supporting Generic Domain Model AR / TS Adopt
Confirm w/
Business
SLIDE 138 vladikk
Ubiquitous Language Bounded Contexts
Protect by
decomposing to Design
Implementation
Core Supporting Generic Domain Model AR / TS Adopt
Confirm w/
Business
SLIDE 139 vladikk
Creative Agency Advertiser
Publisher
Website Placement Ad Zone Ad Type
Target Market
Group Zone Type Funnel Contract Budget Unit
Campaign
Aggregates everywhere!!!
SLIDE 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!!!
SLIDE 142 vladikk
SLIDE 143 THANK YOU!
@vladikk vladikk.com