$30 off During Our Annual Pro Sale. View Details »

Towards Modelling Processes

Towards Modelling Processes

Processes are at the heart of how many businesses operate. The processes are governed by policies, agreed upon with contracts, and guided by documents. In software systems on the other hand, we often bury the processes. There’s a domain model for sure, but it’s all about “things” and “actions”. Let’s explore how Event Sourcing allows us to explicitly model the effects of changes over time.

http://verraes.net/2015/05/towards-modelling-processes/

Mathias Verraes

May 22, 2015
Tweet

More Decks by Mathias Verraes

Other Decks in Programming

Transcript

  1. Towards Modelling Processes
    @mathiasverraes

    View Slide

  2. Mathias Verraes
    verraes.net
    @mathiasverraes
    Independent Software Consultant
    Student of Systems
    Meddler of Models
    Labourer of Legacy

    View Slide

  3. Domain-Driven Design workshops
    verraes.net/workshops

    View Slide

  4. View Slide

  5. Domain-Driven Design
    has evolved a lot
    in +10 years

    View Slide

  6. this talk is about
    things processes
    the grand dichotomy

    View Slide

  7. Great models are
    ╳ an accurate representation of reality
    ✓ useful abstractions
    ✓ solve problems

    View Slide

  8. Use heuristics

    View Slide

  9. Being
    Behaving
    Becoming
    Inspired by ”Rethinking Systems Analysis and Design” — Gerald M. Weinberg

    View Slide

  10. Being
    How it is structured
    Morphology

    View Slide

  11. Behaving
    How it reacts to inputs
    Repeatable, reversible

    View Slide

  12. Becoming
    How it changes into something else
    Evolution

    View Slide

  13. structural modelling
    focus on artefacts

    View Slide

  14. “As a shopper, in order to buy stuff
    Given I have a product X with price EUR100
    When I …”

    View Slide

  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 …”

    View Slide

  16. pseudo-behavioural

    View Slide

  17. imposes a structural model

    View Slide

  18. “As a shopper, in order to buy stuff
    Given the shop owner has priced a product X at EUR100
    When I …”

    View Slide

  19. “Teachers have multiple courses, each with
    multiple modules.
    Students have multiple courses.”

    View Slide

  20. “Courses are only visible when their status is
    Approved”

    View Slide

  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?

    View Slide

  22. Behaving:
    “Only committee members can approve courses”

    View Slide

  23. Becoming:
    “Modules are added and removed”

    View Slide

  24. What happens to students who already completed
    some of the modules that are now obsolete?

    View Slide

  25. time
    event sourcing
    E E E E E E
    A
    E = domain event, A = artefact

    View Slide

  26. event storming

    View Slide

  27. event storming
    E
    Invoice was paid
    time

    View Slide

  28. E
    C
    C = command
    Pay for invoice Invoice was paid
    time

    View Slide

  29. E
    C
    B = business rule
    B
    Pay for invoice Invoice was paid

    View Slide

  30. E
    C B
    Invoice was paid
    Invoice was partially paid
    Pay for invoice
    Paid amount < Invoice amount
    Paid amount = Invoice amount

    View Slide

  31. E
    C B
    Invoice was paid
    Invoice was partially paid
    Paid amount < Invoice amount
    Paid amount = Invoice amount
    Paid amount > Invoice amount
    Invoice was overpaid

    View Slide

  32. E
    C B
    = end of lifecycle
    Invoice was paid

    View Slide

  33. E
    C B
    = depends on
    payment amount
    Pay for invoice

    View Slide

  34. C B
    E
    E
    invoice amount
    Invoice was
    created

    View Slide

  35. C B
    E
    C
    E
    Create invoice

    View Slide

  36. C B
    E
    C
    E C B
    E

    View Slide

  37. C B
    E
    C
    E C B
    E
    All paid amounts < Invoice amount
    All paid amounts = Invoice amount
    All paid amounts > Invoice amount

    View Slide

  38. C B
    E
    C
    E C B
    E
    E
    Invoice was paid
    Invoice was partially paid

    View Slide

  39. the primitives
    of our model

    View Slide

  40. artefacts
    relations
    + foo() behaviour

    View Slide

  41. time
    knowledge
    constraints
    history
    intentions
    branches
    processes
    And more: actors, queries, …

    View Slide

  42. going further…
    actors
    queries
    immediate consistency
    eventual consistency
    aggregates

    View Slide

  43. “Neither a static view
    nor a dynamic view
    can be the whole view.”
    Gerald M. Weinberg — Rethinking Systems Analysis and Design

    View Slide

  44. E E E E
    A
    E E E E
    process process

    View Slide

  45. E E E E E E E E
    collaborative
    construction
    execution
    artefact
    process process

    View Slide

  46. E E E E E E E E
    becoming being behaving

    View Slide

  47. invoice drafting
    invoice document
    invoicing process

    View Slide

  48. invoice drafting
    invoice document
    invoicing process
    the artefact prescribes the execution process

    View Slide

  49. ordering
    receipt
    receiving & putaway

    View Slide

  50. negotiation
    insurance contract
    claim

    View Slide

  51. collaborative
    construction
    execution
    artefact

    View Slide

  52. collaborative
    construction
    execution
    artefact
    analysis
    tracking
    feedback

    View Slide

  53. invoice drafting
    invoice document
    invoicing process
    implicit internal policy

    View Slide

  54. invoice drafting
    invoice document
    invoicing process
    explicit policy

    View Slide

  55. invoice drafting
    invoice document
    invoicing process
    evolving policy

    View Slide

  56. invoice drafting
    invoice document
    invoicing process
    evolving policy

    View Slide

  57. configurable policies per tenant
    ordering
    receipt
    receiving & putaway

    View Slide

  58. product changes
    negotiation
    insurance contract
    claim
    internal policy

    View Slide

  59. implementation
    suggestions

    View Slide

  60. Processes with:
    Immediately consistent rules
    => aggregates
    Eventually consistent rules
    => process managers

    View Slide

  61. 1 2 3 4
    policy changes
    Versioning
    2
    E E E
    B B
    1
    2
    3
    4
    2 2

    View Slide

  62. E E E
    1 2 3 4
    policy changes
    Specification
    B B

    View Slide

  63. E E E
    1 2 3 4
    policy changes
    Specification
    B B
    auditing

    View Slide

  64. E E E
    1 2 3 4
    policy changes
    Strategy
    B B

    View Slide

  65. E E E
    1 2 3 4
    policy changes
    Running process affected by policy changes
    B B

    View Slide

  66. complex business
    problems require a
    temporal model

    View Slide

  67. “The only reason
    for time
    is so that
    everything
    doesn’t happen
    at once.”
    Albert Einstein

    View Slide

  68. @mathiasverraes
    verraes.net
    dddeurope.com
    Brussels, January 2016

    View Slide