Slide 1

Slide 1 text

7 YEARS OF DDD: TACKLING COMPLEXITY
 IN LARGE SCALE MARKETING SYSTEMS

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

AGENDA

Slide 5

Slide 5 text

PART 1
 5 BOUNDED CONTEXTS PART 2 PRACTICAL ADVICE

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

YAY!!!

Slide 8

Slide 8 text

Your Product Marketing
 Strategy Creatives Campaigns Sales
 Agents Optimization Profits

Slide 9

Slide 9 text

THE FIRST BOUNDED CONTEXT 01

Slide 10

Slide 10 text

VER 1.0 Media Buying Creatives Catalog Campaign Management

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

Very nice!

Slide 14

Slide 14 text

Aggregates everywhere!!!

Slide 15

Slide 15 text

Aggregates everywhere!!! Creative Agency Advertiser Publisher Website Placement Ad Zone Ad Type Target Market Group Zone Type Funnel Contract Budget Unit Campaign

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

Domain Model Service / Application Layer Presentation Infrastructure Anemic! Behaviour

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

UBIQUITOUS LANGUAGE

Slide 20

Slide 20 text

Domain Expert Software Developer Has no experience in online marketing Nice people!

Slide 21

Slide 21 text

Smooth communication Strong grasp of the business domain Working software Aggressive time to market

Slide 22

Slide 22 text

Ubiquitous Language Anemic Domain Model

Slide 23

Slide 23 text

Leads Sales Agents Ads

Slide 24

Slide 24 text

Leads CRM Categorize Desk Desk Desk Sales Agents Sales Agents Sales Agents Clients’ Systems

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

Lead qualification Agent qualification Agents’ commissions

Slide 27

Slide 27 text

THE CRM BOUNDED CONTEXT 02

Slide 28

Slide 28 text

Ubiquitous Language Anemic Domain Model

Slide 29

Slide 29 text

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 30

Slide 30 text

Domain Expert Software Developer …. Lead …. …. Campaign…

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

BOUNDED CONTEXTS PROTECT THE LANGUAGE AGGREGATES PROTECT CONSISTENCY OF DATA

Slide 34

Slide 34 text

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 35

Slide 35 text

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 36

Slide 36 text

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

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

Stored procedures???

Slide 42

Slide 42 text

Group Desk Qualification Assessment Organization Unit Assignment Rank Message On-site Activity Brand Lead Campaign Lead

Slide 43

Slide 43 text

L e a d CRM Team DBA Team

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

Inconsistent models No shared understanding Duplication of knowledge Went out of sync quickly NIGHTMARE

Slide 46

Slide 46 text

Wasn’t delivered on time Production issues Data corruption Thrown away and reimplemented

Slide 47

Slide 47 text

Ubiquitous Language Domain Model Bounded Contexts Protect w/ Implement as

Slide 48

Slide 48 text

Ubiquitous Language Domain Model Bounded Contexts Protect w/ Implement as …Dude, where are Sub-Domains?

Slide 49

Slide 49 text

Not all of a large system will be well designed “ Eric Evans

Slide 50

Slide 50 text

THE CRUNCHERS BOUNDED CONTEXT 03

Slide 51

Slide 51 text

Marketing CRM Analysis Customer Events Marketing CRM

Slide 52

Slide 52 text

Marketing CRM Analysis Customer Events Event Crunchers

Slide 53

Slide 53 text

Competitive advantage? - No Off-the-shelve solution? - No => Supporting sub-domain

Slide 54

Slide 54 text

Layered Architecture Transaction Script Worked …. for a while

Slide 55

Slide 55 text

Customer Events Event Crunchers Marketing CRM Analysis Flag Flag Calculated fields

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

Marketing CRM Analysis Customer Events Event Crunchers

Slide 58

Slide 58 text

Customer Events Event Crunchers (BBOM) CRM Marketing Analysis

Slide 59

Slide 59 text

Customer Events Event Crunchers (Event Sourced) CRM Marketing Analysis

Slide 60

Slide 60 text

THE BONUSES BOUNDED CONTEXT 04

Slide 61

Slide 61 text

Sales Commissions Reports

Slide 62

Slide 62 text

Competitive advantage? - No Off-the-shelve solution? - No => Supporting sub-domain

Slide 63

Slide 63 text

Active Record Service / Application Layer Presentation Infrastructure

Slide 64

Slide 64 text

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!

Slide 65

Slide 65 text

Active Record Service / Application Layer Presentation Infrastructure BIG BALL OF MUD

Slide 66

Slide 66 text

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

Slide 67

Slide 67 text

Active Record Service / Application Layer Presentation Infrastructure Transaction Script Service / Application Layer Presentation Infrastructure Event Crunchers Bonuses Ubiquitous Language

Slide 68

Slide 68 text

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

Slide 69

Slide 69 text

Ubiquitous Language Core Bounded Contexts Protect by
 decomposing to Identify Domains Domain Model Supporting Generic AR / TS Adopt Implement as

Slide 70

Slide 70 text

THE MARKETING HUB BOUNDED CONTEXT 05

Slide 71

Slide 71 text

Leads Marketing Hub Client Client Client

Slide 72

Slide 72 text

Competitive advantage? - Yes => Core Domain

Slide 73

Slide 73 text

Event Sourced Domain Model CQRS Microservices

Slide 74

Slide 74 text

Micro
 Service Micro
 Service Micro
 Service Micro
 Service

Slide 75

Slide 75 text

Aggregate Aggregate Aggregate Aggregate

Slide 76

Slide 76 text

Aggregate Aggregate Aggregate Aggregate Event Sourced
 Aggregate

Slide 77

Slide 77 text

Aggregate Aggregate Aggregate Aggregate Event Sourced
 Aggregate

Slide 78

Slide 78 text

Event Sourced Domain Model CQRS Microservices

Slide 79

Slide 79 text

Aggregate Aggregate Aggregate Aggregate Event Sourced
 Aggregate

Slide 80

Slide 80 text

TECHNICAL COMPLEXITY BUSINESS COMPLEXITY >

Slide 81

Slide 81 text

Aggregate Aggregate Aggregate Aggregate Event Sourced
 Aggregate

Slide 82

Slide 82 text

Marketing Bonuses U D CRM U D Marketing
 Hub U U D D Event Crunchers U D U D

Slide 83

Slide 83 text

WHAT
 WE HAVE L E A R N E D

Slide 84

Slide 84 text

UBIQUITOUS LANGUAGE 01

Slide 85

Slide 85 text

Ubiquitous Language: The Core Domain of Domain-Driven Design

Slide 86

Slide 86 text

UBIQUITOUS LANGUAGE DOCUMENTS TESTS JIRA >

Slide 87

Slide 87 text

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 88

Slide 88 text

Invest in the Ubiquitous Language early on.

Slide 89

Slide 89 text

Cheap!

Slide 90

Slide 90 text

You don’t need a budget for a Ubiquitous Language

Slide 91

Slide 91 text

DOMAIN TYPES 02

Slide 92

Slide 92 text

Core Supporting Generic

Slide 93

Slide 93 text

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

Slide 94

Slide 94 text

COMPANIES CHANGE, EVOLVE, REINVENT THEMSELVES DOMAINS' TYPES CAN CHANGE ACCORDINGLY

Slide 95

Slide 95 text

SUPPORTING ➤ CORE • Event Crunchers • Bonuses SUPPORTING ➤ GENERIC • Creative Catalog CORE ➤ GENERIC • Lead Evaluation System CORE ➤ SUPPORTING • Marketing Hub GENERIC ➤ CORE • AWS

Slide 96

Slide 96 text

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

Slide 97

Slide 97 text

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

Slide 98

Slide 98 text

Less waste Dialog with the business IMPLEMENTATION DESIGN ➤ DOMAIN TYPE

Slide 99

Slide 99 text

• Questionable competitive edge? • Accidental “business” complexity? • Unexpected competitive edge? BUSINESS COMPLEXITY ≠ DOMAIN TYPE?

Slide 100

Slide 100 text

Generic Domain Adopt / Buy Supporting Domain Active Record / Transaction Script Core Domain Domain Model / Event Sourcing IMPLEMENTATION DESIGN ➤ DOMAIN TYPE

Slide 101

Slide 101 text

IMPLEMENTATION STRATEGIES 03

Slide 102

Slide 102 text

How to Model the Business Logic? Transaction Script Active Record Domain Model Event Sourced Domain Model

Slide 103

Slide 103 text

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 104

Slide 104 text

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

Slide 105

Slide 105 text

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

Slide 106

Slide 106 text

Transaction Script Active Record Domain Model Event Sourced Domain Model

Slide 107

Slide 107 text

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

Slide 108

Slide 108 text

Transaction Script Active Record Domain Model Event Sourced Domain Model

Slide 109

Slide 109 text

CQRS 04

Slide 110

Slide 110 text

Event Sourcing ➤ CQRS

Slide 111

Slide 111 text

EVENT SOURCING A WAY OF MODELING BUSINESS DOMAINS CQRS ARCHITECTURAL PATTERN FOR REPRESENTING THE SAME DATA IN DIFFERENT MODELS

Slide 112

Slide 112 text

Transaction Script Active Record Domain Model } Can benefit from CQRS and State-Based Projections

Slide 113

Slide 113 text

05 BOUNDED CONTEXTS

Slide 114

Slide 114 text

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 115

Slide 115 text

Bonuses Event Crunchers DOMAIN-BASED BOUNDARIES

Slide 116

Slide 116 text

AGGREGATE-BASED BOUNDARIES Aggregate Aggregate Aggregate Aggregate

Slide 117

Slide 117 text

L e a d SUICIDAL BOUNDARIES

Slide 118

Slide 118 text

No content

Slide 119

Slide 119 text

Finding service boundaries is really damn hard… There is no flowchart! “ Udi Dahan

Slide 120

Slide 120 text

THERE ARE GOING TO BE MISTAKES ACCEPT IT, AND DON’T MAKE FATAL ONES

Slide 121

Slide 121 text

START WITH BIGGER BOUNDARIES DECOMPOSE LATER, AS YOU GAIN KNOWLEDGE

Slide 122

Slide 122 text

THE LESS YOU KNOW ABOUT THE DOMAIN - THE WIDER THE INITIAL BOUNDARIES ARE

Slide 123

Slide 123 text

Aggregate Aggregate Aggregate Aggregate Event Sourced
 Aggregate

Slide 124

Slide 124 text

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 125

Slide 125 text

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 126

Slide 126 text

START WITH BIGGER BOUNDARIES DECOMPOSE AS YOU GAIN DOMAIN KNOWLEDGE

Slide 127

Slide 127 text

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

Slide 128

Slide 128 text

07 SUMMARY

Slide 129

Slide 129 text

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

Slide 130

Slide 130 text

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

Slide 131

Slide 131 text

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

Slide 132

Slide 132 text

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

Slide 133

Slide 133 text

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

Slide 134

Slide 134 text

Creative Agency Advertiser Publisher Website Placement Ad Zone Ad Type Target Market Group Zone Type Funnel Contract Budget Unit Campaign Aggregates everywhere!!!

Slide 135

Slide 135 text

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 136

Slide 136 text

P.S.

Slide 137

Slide 137 text

No content

Slide 138

Slide 138 text

QUESTIONS?

Slide 139

Slide 139 text

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