Page 1
Towards Modelling Processes@mathiasverraes
Page 2
Mathias Verraes verraes.net
@mathiasverraes
Independent Software Consultant
Student of Systems Meddler of Models Labourer of Legacy
Page 3
Domain-Driven Design workshops verraes.net/workshops
Page 5
Domain-Driven Design has evolved a lot
in +10 years
Page 6
this talk is about
things processes
the grand dichotomy
Page 7
Great models are
╳ an accurate representation of reality ✓ useful abstractions ✓ solve problems
Page 9
Being Behaving Becoming
Inspired by ”Rethinking Systems Analysis and Design” — Gerald M. Weinberg
Page 10
Being How it is structured
Morphology
Page 11
Behaving How it reacts to inputs Repeatable, reversible
Page 12
Becoming How it changes into something else
Evolution
Page 13
structural modelling
focus on artefacts
Page 14
“As a shopper, in order to buy stuff Given I have a product X with price EUR100
When I …”
Page 15
“As a shop owner, in order to sell stuff Given I have a product X,
And that product is priced EUR 100 in the pricing table When I …”
Page 16
pseudo-behavioural
Page 17
imposes a structural model
Page 18
“As a shopper, in order to buy stuff Given the shop owner has priced a product X at EUR100
When I …”
Page 19
“Teachers have multiple courses, each with multiple modules.
Students have multiple courses.”
Page 20
“Courses are only visible when their status is Approved”
Page 21
What changes? Why does it change?
Under what circumstances? Who changes it?
How often does it change?
What are the consequences of that change?
Page 22
Behaving: “Only committee members can approve courses”
Page 23
Becoming: “Modules are added and removed”
Page 24
What happens to students who already completed some of the modules that are now obsolete?
Page 25
time
event sourcing
E E E E E E
A
E = domain event, A = artefact
Page 27
event storming
EInvoice was paid
time
Page 28
EC
C = command
Pay for invoice Invoice was paid
time
Page 29
EC
B = business rule
BPay for invoice Invoice was paid
Page 30
EC B
Invoice was paid
Invoice was partially paidPay for invoice
Paid amount < Invoice amount Paid amount = Invoice amount
Page 31
E
C BInvoice was paid
Invoice was partially paid
Paid amount < Invoice amount Paid amount = Invoice amount Paid amount > Invoice amount
Invoice was overpaid
Page 32
E
C B
= end of lifecycle
Invoice was paid
Page 33
E
C B
= depends on
payment amountPay for invoice
Page 34
C BE
E
invoice amount
Invoice was created
Page 35
C BEC
ECreate invoice
Page 37
C BEC
E C B
E
All paid amounts < Invoice amount All paid amounts = Invoice amount All paid amounts > Invoice amount
Page 38
C BEC
E C B
E
E
Invoice was paidInvoice was partially paid
Page 39
the primitives of our model
Page 40
artefacts
relations
+ foo() behaviour
Page 41
timeknowledge
constraints history
intentions branches
processes
And more: actors, queries, …
Page 42
going further…
actors queries
immediate consistency eventual consistency
aggregates
Page 43
“Neither a static view nor a dynamic view
can be the whole view.”
Gerald M. Weinberg — Rethinking Systems Analysis and Design
Page 44
E E E E
A
E E E E
process process
Page 45
E E E E E E E E
collaborative construction executionartefact
process process
Page 46
E E E E E E E E
becoming being behaving
Page 47
invoice drafting
invoice documentinvoicing process
Page 48
invoice drafting
invoice documentinvoicing process
the artefact prescribes the execution process
Page 49
orderingreceipt
receiving & putaway
Page 50
negotiationinsurance contract
claim
Page 51
collaborative construction executionartefact
Page 52
collaborative construction executionartefact
analysis
tracking
feedback
Page 53
invoice drafting
invoice documentinvoicing process
implicit internal policy
Page 54
invoice drafting
invoice documentinvoicing process
explicit policy
Page 55
invoice drafting
invoice documentinvoicing process
evolving policy
Page 56
invoice drafting
invoice documentinvoicing process
evolving policy
Page 57
configurable policies per tenant
orderingreceipt
receiving & putaway
Page 58
product changes
negotiationinsurance contract
claim
internal policy
Page 59
implementation suggestions
Page 60
Processes with:
Immediately consistent rules => aggregates
Eventually consistent rules => process managers
Page 61
1 2 3 4
policy changes
Versioning
2
E E EB B
1 2 3 4
2 2
Page 62
E E E
1 2 3 4
policy changes
Specification
B B
Page 63
E E E
1 2 3 4
policy changes
Specification
B B
auditing
Page 64
E E E
1 2 3 4
policy changes
Strategy
B B
Page 65
E E E
1 2 3 4
policy changes
Running process affected by policy changes
B B
Page 66
complex business problems require a
temporal model
Page 67
“The only reason
for time is so that
everything doesn’t happen
at once.”
Albert Einstein
Page 68
@mathiasverraes verraes.net
dddeurope.com Brussels, January 2016