Slide 1

Slide 1 text

Extreme DDD Modelling patterns @ziobrando 2024

Slide 2

Slide 2 text

Disclaimer In Domain-Driven Design since the early days In love with CQRS/ES and EventStorming Enjoying modelling without trade-offs Running My own company Unusual freedom Eating my own gourmet dogfood

Slide 3

Slide 3 text

The account that wasn’t Quick intro

Slide 4

Slide 4 text

Context Simple Treasury Module: we need to know the available liquidity in different accounts Multiple account types, no integrations via API (we’re too small/lazy/Poor)

Slide 5

Slide 5 text

So… • We need an account. name currentBalance Account deposit withdraw

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Pick your poison name currentBalance Account deposit withdraw Incoherent design Someone else’s model bank Not the domain name name currentBalance lastUpdatedOn Account registerSnapshot trackOperation name currentBalance lastUpdatedOn AccountTracker registerSnapshot trackOperation

Slide 8

Slide 8 text

Consistent with User’s Expectation Coherent with semantics name currentBalance lastUpdatedOn Account registerSnapshot trackOperation name currentBalance lastUpdatedOn AccountTracker registerSnapshot trackOperation 😵 Ubiquitous Language? Account

Slide 9

Slide 9 text

Labels can make you happy Account

Slide 10

Slide 10 text

Danger Zone! • Why did we pick the wrong model first? • Kahneman’s System one? • …There’s a little backdoor in our brain that allows school examples to bypass validation • Including examples from speakers on a stage name currentBalance Account deposit withdraw

Slide 11

Slide 11 text

The Dictionary Interlude

Slide 12

Slide 12 text

context Long Lasting Project (3+ Years) in a large organisation Complex domain with a very specific jargon Legacy core Glossary built with the best intentions Still trapped in special cases

Slide 13

Slide 13 text

The revelation Photo by Joshua Earle on Unsplash

Slide 14

Slide 14 text

Every single term from Marketing was crap!

Slide 15

Slide 15 text

I’ll follow you everywhere my beloved domain expert!! I have no clue where I am going…

Slide 16

Slide 16 text

Not every information from the “expert” is suitable to become part of our model

Slide 17

Slide 17 text

Room Reservations Some are assigned at purchase time Some are assigned at departure time Rooms can be sold with ancillary services Upgrades are possible Money can buy almost everything

Slide 18

Slide 18 text

Labels can make you happy All Inclusive Bundle Catalog Item Not cool enough to be mentioned by marketing

Slide 19

Slide 19 text

Maybe we’re not selling our inventory after all… Maybe we’re always selling a bundle, which sometimes is simple 🤔 🤔

Slide 20

Slide 20 text

A Flat Dictionary can be a force in the wrong direction 💡 Make sure your Dictionary reflects your bounded contexts

Slide 21

Slide 21 text

Experts grown on legacy, will guide you to rebuild the legacy

Slide 22

Slide 22 text

Complex Software in the small Or: “how not to grow a Big Ball of Mud”

Slide 23

Slide 23 text

Bounded Context • Limit of applicability of a model • Unit of language consistency • A single model tailored around a specific purpose Bounded Context

Slide 24

Slide 24 text

Good, but not actionable

Slide 25

Slide 25 text

Proxies to the rescue • Every proxy has a variable accuracy • Unfortunately, most of these proxies are only visible in large organisations Bounded Context Limit of applicability of a model Team Subdomain Organization Technology Legacy

Slide 26

Slide 26 text

And of course…

Slide 27

Slide 27 text

In small Organizations… • People, teams and department stop being relevant • Everything is pulling towards a monolith • All we’re left with is Purpose and Business Lines

Slide 28

Slide 28 text

Is this our Destiny?

Slide 29

Slide 29 text

In the small scale • Single database -> Flat Namespace • Single Project -> IDE doesn’t like Polysemic words • Small Team -> The Mental Model naturally tends towards a Flat Namespace

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

Designing to grow right

Slide 32

Slide 32 text

Possible Bounded Contexts Trainings Consulting Planning Marketing Sales Billing Logistics Webinars Is Trainings a Bounded Context? Finance

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

Our idea: Separate on purpose Logical separation only (easily reversible mistakes) See what happens

Slide 35

Slide 35 text

Mixing is cheaper than Splitting

Slide 36

Slide 36 text

Dogfood!

Slide 37

Slide 37 text

Business Lines first! Books Public Trainings Private Trainings Consulting Sponsorships Public Speaking Software Delivery Meetups Events Obvious in the large, but our responsibility in the small.

Slide 38

Slide 38 text

Then “Phases” Books Public Trainings Private Trainings Consulting Sponsorships Public Speaking Software Delivery Meetups Events Planning Sales Delivery Billing Product Design Financial Analysis Strategy Marketing Inventory

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

Where are they coming from? 10 years of Orange Stickies on paper rolls? Independent forces for change? Some “standard” departments Gut Feeling? Perfection is not the goal

Slide 41

Slide 41 text

Then Purposes -> Models Something is still missing, but …you got the point Books Public Trainings Private Trainings Consulting Sponsorships Public Speaking Software Delivery Meetups Events Planning Sales Delivery Billing Product Design Financial Analysis Strategy Marketing Inventory Date Picking Tracking Value Tickets and discounts Print on Demand Personal Availability Engagement Strategy Deals Pricing Budget Contracts & Engagement Partnerships Forecast Global Analysis Billing Billing Scouting Date Picking Content design Review Logistics Scouting Courseware and certificates Newsletter & social Newsletter & social Content Design Format Design

Slide 42

Slide 42 text

Bounded Contexts on a grid 🙂 Shapes and Distribution Matters 🧐 Commonalities are visible 🧐 More precise names & purposes 😎 Better project structure in the IDE We definitely need a map! Books Public Trainings Private Trainings Consulting Sponsorships Public Speaking Software Delivery Meetups Events Planning Sales Delivery Billing Product Design Financial Analysis Strategy Marketing Inventory Date Picking Tracking Value Tickets and discounts Print on Demand Personal Availability Engagement Strategy Deals Pricing Budget Contracts & Engagement Partnerships Forecast Global Analysis Billing Billing Scouting Date Picking Content design Review Logistics Scouting Courseware and certificates Newsletter & social Newsletter & social Content Design Format Design

Slide 43

Slide 43 text

On a single business line… It’s a value-creation network! Looks a lot like EventStorming 😎 Public Trainings Planning Sales Delivery Billing Product Design Financial Analysis Strategy Marketing Inventory Tickets and discounts Deals Pricing Global Analysis Billing Date Picking Logistics Scouting Courseware and certificates Newsletter & social Content Design Reservations

Slide 44

Slide 44 text

Yummy!

Slide 45

Slide 45 text

Modelling our own flow(s) And being radical about it

Slide 46

Slide 46 text

The Draft-Executable-Tracking Archetype Draft Model Executable Tracking Easy to change, possibly partially specified Solid, running on read- only data Collecting or visualizing Validation Different Models, very similar languages, different paradigms

Slide 47

Slide 47 text

Visual Grammar Aggregate Read Model Command Value Object? Policy Event Person Unit of transactional consistency Something that happened: verb in part tense Command Reactive logic: “Whenever (event) then (command) The information needed to decide Read Model External System

Slide 48

Slide 48 text

A little more complex: Design Planning Sales Inventory Logistics Tracking Training Summary Public Event Open Event Printables Venue Booking Ticket Sale Purchase Aggregate Read Model

Slide 49

Slide 49 text

A little more complex Design Planning Sales Inventory Logistics Tracking Training Summary Public Event Ticket Sale Open Event Printables Register Attendee Purchase Ticket Open Sales Schedule Confirm Cancel Close Sales Cancel Attendee Session Plan Ticket Plan …other possible Value Objects Open Registra tions (capacity) Close Registrations Venue Booking Purchase

Slide 50

Slide 50 text

Policies to connect-1 Design Planning Sales Inventory Logistics Tracking Training Summary Public Event Ticket Sale Open Event Printables Register Attendee Purchase Ticket Open Sales Schedule Confirm Cancel Close Sales Cancel Attendee Session Plan Ticket Plan … Public Training Event Coordination Open Registra tions (capacity) Close Registrations Venue Booking Purchase

Slide 51

Slide 51 text

Policies to connect-2 Design Planning Sales Inventory Logistics Tracking Training Summary Public Event Ticket Sale Open Event Printables Register Attendee Reserve Ticket Open Sales Schedule Confirm Cancel Close Sales Cancel Attendee Session Plan Ticket Plan … PTE Policy Open Registra tions (capacity) Close Registrations Registration Policy Ticket Purchased Attendee Registered Courseware Policy One more! Venue Booking Purchase Ticket Reservation Policy Purchase Started Purchase Completed Assign Ticket

Slide 52

Slide 52 text

Read Models to summarise Design Planning Sales Inventory Logistics Tracking Training Summary Public Event Ticket Sale Open Event Printables Register Attendee Purchase Ticket Open Sales Schedule Confirm Cancel Close Sales Cancel Attendee Session Plan Ticket Plan … PTE Policy Open Registra tions (capacity) Close Registrations Ticket Purchased Attendee Registered Event Confirmed Purchase

Slide 53

Slide 53 text

All good?

Slide 54

Slide 54 text

Naming pain Design Planning Sales Inventory Logistics Tracking Training Summary Public Event Ticket Sale Open Event Printables Register Attendee Purchase Ticket Open Sales Schedule Confirm Cancel Close Sales Cancel Attendee Session Plan Ticket Plan … Public Training Event Coordination Policy Open Registra tions (capacity) Close Registrations Ticket Purchased Attendee Registered Event Confirmed Horrible names Venue Booking Purchase Experts will Keep using the specific terms like “Meetup” “Training” or “Conference”

Slide 55

Slide 55 text

Redundancy Pain Design Planning Sales Inventory Logistics Tracking Training Summary Public Event Ticket Sale Open Event Printables Register Attendee Purchase Ticket Open Sales Schedule Confirm Cancel Close Sales Cancel Attendee Session Plan Ticket Plan … Public Training Event Coordination Policy Open Registra tions (capacity) Close Registrations Ticket Purchased Attendee Registered Event Confirmed Double Capacity? Venue Booking

Slide 56

Slide 56 text

YaGNI!!!

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

A single use case might not be enough We are in the core: some principles are not dogmas 🤔 🤔

Slide 59

Slide 59 text

Private Trainings Design Planning Sales Inventory Logistics Tracking Training Summary Public Event Deal Open Event Printables Register Attendee Schedule Confirm Cancel Cancel Attendee Session Plan … Private Training Coordination Policy Open Registra tions (capacity) Close Registrations Attendee Registered Event Confirmed Private Training Coordination Policy Deal signed Materials Printed Very Limited changes, without opening boxes. Printables

Slide 60

Slide 60 text

Online Training Design Planning Sales Inventory Logistics Tracking Training Summary Public Event Ticket Sale Open Event Printables Register Attendee Purchase Ticket Open Sales Schedule Confirm Cancel Close Sales Cancel Attendee Session Plan Ticket Plan … Public Online Training Policy Open Registra tions (capacity) Close Registrations Registration Policy Ticket Purchased Attendee Registered Courseware Policy One more! Delivery Online Session Schedule Start Purchase Very Limited changes, without opening boxes.

Slide 61

Slide 61 text

Business-Driven Stressors Can I have [This] without [That]? Can I have [Reservations] without a [Ticket]? Is this the Exception or the Rule? It’s always a [Bundle], sometimes a simple one. Can I have [This] and [That]?

Slide 62

Slide 62 text

Online Private Design Planning Sales Inventory Logistics Tracking Training Summary Public Event Deal Open Event Printables Register Attendee Schedule Confirm Cancel Cancel Attendee Session Plan Ticket Plan … Private Online Training Policy Open Registra tions (capacity) Close Registrations Attendee Registered Courseware Policy One more! Delivery Online Session Schedule Start Deal signed Progressively declining cost of new options

Slide 63

Slide 63 text

More Options Hybrid Trainings Combo Tickets Composite Events Resellers and Partners Conferences and Workshops Books as Courseware

Slide 64

Slide 64 text

Top-Down Forces Interacting with Domain Experts Detecting Business Lines Imposing phases and archetypes

Slide 65

Slide 65 text

Bottom-Up Forces Detecting Building Blocks - Types Making Them Safe

Slide 66

Slide 66 text

Session Layout • Originally ok with int duration • Pandemic as a majestic stressor: • Exact Timing became vital information for online sessions • Empty spaces become interesting for different activity types Session Layout

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

Parallel Models Design Delivery Session Plan Session Type Session Session Duration Session Schedule Scheduled Session On May 17th On may 17th, 9:30 am 3 Days Day 1, 9:30 am Session Type Zoom Google Calendar

Slide 69

Slide 69 text

For Reuse!!!

Slide 70

Slide 70 text

For Business Composability!!!

Slide 71

Slide 71 text

How much of this journey can involve domain experts? I suspect “It Depends” is a clear winner here. 🤔 🤔

Slide 72

Slide 72 text

Feeling guilty Design Delivery Session Plan Session Type Session Session Duration Session Schedule Scheduled Session Horrible names On May 17th On may 17th, 9:30 am 3 Days Day 1, 9:30 am Session Type

Slide 73

Slide 73 text

Problem with this pattern? Experts think they’re talking about the same thing: You know they’re not Draft Model Executable Tracking Validation Propose Adjust Annotate Comment Finalize Schedule Cancel Session Session Type Session Session Type Duration Schedule Duration Comment Measure Start Join Terminate Session Session Type Duration

Slide 74

Slide 74 text

What is visible? Session Plan Ticket Plan Training Summary Schedule Public Event Ticket Sale Open Event Session Type Session Session Duration Session Can Domain Experts help here?

Slide 75

Slide 75 text

State as an Illusion The final trick!

Slide 76

Slide 76 text

I’ll follow you everywhere my beloved domain expert!!

Slide 77

Slide 77 text

Read Model Con fi rm Retire Amazing Workshop With John Doe June 25 - 2023 90 days till deadline 5 of 16 ticket sold UNCONFIRMED Threshold at 8 - John Smith - Early Bird Ticket - Mario Rossi - Early Bird Ticket - Francesca Bianchi - Early Bird Ticket - Sylvie Bouchard - Standard Ticket - Nick Fury - Special Ticket The information needed to make a decision A few things are missing, I am lazy

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

That’s what you want to see!

Slide 80

Slide 80 text

There’s more than one! Planning: Time: Registration / Sales:

Slide 81

Slide 81 text

I can show you Everything! I just need to see: UNCONFIRMED CONFIRMED RUNNING PAST CANCELED

Slide 82

Slide 82 text

User Perceived State Machine UNCONFIRMED CONFIRMED RUNNING PAST CANCELED

Slide 83

Slide 83 text

User Perceived State Machine Sales Event Time Read Model Closed Unconfirmed Future Stealth Closed Confirmed Future Confirmed Closed Canceled Future Canceled Open Unconfirmed Future Unconfirmed Open Confirmed Future Confirmed Open Canceled Future Error Closed Unconfirmed Present Forgot something? Closed Confirmed Present Running Closed Canceled Present 😭😭😭😭😭😭😭 Open … Present Hey Wait a Minute! … … … …

Slide 84

Slide 84 text

Surprise states!

Slide 85

Slide 85 text

But…

Slide 86

Slide 86 text

I’ll couple everything to give you the state machine you want!

Slide 87

Slide 87 text

It’s an illusion!

Slide 88

Slide 88 text

No content

Slide 89

Slide 89 text

Spice up your models! Photo by Tamanna Rumee on Unsplash

Slide 90

Slide 90 text

No content

Slide 91

Slide 91 text

Give yourself more than one option

Slide 92

Slide 92 text

Add Layers to your whirlpool!

Slide 93

Slide 93 text

Low-fi Matters

Slide 94

Slide 94 text

Digital Tools are changing your brain priorities I enter a session to model, and I find myself aligning rectangles and making arrows clear.

Slide 95

Slide 95 text

Get Yourself a Green Bar!

Slide 96

Slide 96 text

Combining Different Styles Little Cherry on top

Slide 97

Slide 97 text

A Scatter-Gather Style Design Planning Sales Inventory Logistics Tracking Training Summary Public Event Open Event Printables Venue Booking Ticket Sale Purchase State-Based Aggregates (or nobody cares about your intermediate events anyway) Structural composition and possible collaboration Specifications as warnings. Read Models on Steroids, focus on information readability and sense-making for the users. EventSourcing on multiple parallel axes: events are meaningful for the listeners Policies -> Sagas or Process Managers to allow business flexibility Draft Executable Tracking Possible upscale to state-driven style Title

Slide 98

Slide 98 text

Pick the right tool for the job

Slide 99

Slide 99 text

Maybe we can avoid it!

Slide 100

Slide 100 text

Lightweight Boundaries Postpone physical separation as long as you can. Make sure your team has enough discipline to support the logical separation.

Slide 101

Slide 101 text

Wrap up!

Slide 102

Slide 102 text

Biases and shortcuts are nudging you to repeat past errors

Slide 103

Slide 103 text

I’ll follow you everywhere my beloved domain expert!! Why don’t we just patch the legacy?

Slide 104

Slide 104 text

Sometimes we gotta Pull! Photo by Ugur Arpaci on Unsplash

Slide 105

Slide 105 text

Design Integrity is YOUR BUSINESS

Slide 106

Slide 106 text

Can’t outsource it to the Domain Expert

Slide 107

Slide 107 text

You Can Start Clean Quick and Dirty is not the only option

Slide 108

Slide 108 text

Give yourself one more alternatives Your 1st choice is probably unsafe

Slide 109

Slide 109 text

What is visible? Session Plan Ticket Plan Training Summary Schedule Public Event Ticket Sale Open Event Session Type Session Session Duration Session Can Domain Experts help here?

Slide 110

Slide 110 text

What is visible? Read Models Aggregates UI Not everything needs to be discussed in the same way Commands (Labels and Intentions) Commands Events Policies

Slide 111

Slide 111 text

Business Composability Is Business Confidence But make sure it comes from code, not from PowerPoints

Slide 112

Slide 112 text

Business Composability Is Model Confidence

Slide 113

Slide 113 text

Thanks!

Slide 114

Slide 114 text

References • www.eventstorming.com • LeanPub books: • http://leanpub.com/introducing_eventstorming (still growing) • https://leanpub.com/ddd_first_15_years • Blog: • https://medium.com/@ziobrando • http://ziobrando.blogspot.com • http://blog.avanscoperta.it • Twitter: @ziobrando • Trainings & Workshop facilitation: [email protected] • http://www.avanscoperta.it