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

On Being Explicit

On Being Explicit

DDD London
November 9 2016

On Being Explicit

“Make the implicit explicit” must be one of the most valuable advices I ever got about software modelling and design. Gather around for some tales from the trenches: stories from software projects where identifying a missing concept, and bringing it front and centre, turned the model inside out. Our tools: metaphors, pedantry, type systems, the age old heuristic of “Follow the money”, visual models, and a healthy obsession with language.

Mathias Verraes
@mathiasverraes
http://verraes.net

Mathias Verraes advises companies on building software for complex environments. This involves primarily analysis and modelling, but also code, architecture, testing, and refactoring “unmaintainable” systems. He has worked with clients in Finance, Automotive, Government, Logistics, E-Commerce, and more. He teaches Domain-Driven Design courses and co-organises the DDD Europe conference. When he’s not working, he’s at home in Kortrijk, Belgium, helping his two sons build crazy Lego train tracks.

Mathias Verraes

November 10, 2016
Tweet

More Decks by Mathias Verraes

Other Decks in Technology

Transcript

  1. View Slide

  2. On Being Explicit
    @mathiasverraes
    verraes.net
    Software consulting
    for complex environments

    View Slide

  3. View Slide

  4. Two day conference ticket
    €599 instead of €699
    bit.ly/bddx-november

    View Slide

  5. Logger
    {
    log(...)
    {
    ...
    }
    }

    View Slide

  6. A healthy obsession
    with language

    View Slide

  7. View Slide

  8. Log
    {
    append(...)
    {
    ...
    }
    }

    View Slide

  9. Make the implicit explicit
    What are we really doing?
    What missing concepts can we identify?
    How can we bring them forward?

    View Slide

  10. Example:1
    Money
    1 http://verraes.net/2016/02/type-safety-and-money/

    View Slide

  11. Support multiple currencies
    8 decimal precision for calculations
    Use currency's official division in UIs and APIs
    Compliance reporting in select markets
    Convert to € for internal reporting

    View Slide

  12. Testable != idiot-proof2
    2 Typical idiots include future self

    View Slide

  13. * You may not want to use floats.
    "Patterns of Enterprise Application Architecture", Martin Fowler, 2002

    View Slide

  14. Constructor enforces decimals.
    Operations protect against wrong currencies.

    View Slide

  15. a = new Money(1.123456789, eur)
    // The constructor rounds it to 1.12345679
    b = a.round()
    // rounds it to 1.12 and
    // instantiates a new Money
    // The constructor rounds it to 1.12000000
    c = a.add(b)
    // icky

    View Slide

  16. PreciseMoney {
    round() : RoundedMoney {
    return new RoundedMoney(amount, currency)
    }
    ...
    }
    RoundedMoney {
    add(RoundedMoney other) : RoundedMoney {...}
    multiply(Float operand) : PreciseMoney {...}
    ...
    }

    View Slide

  17. View Slide

  18. RoundedMoney {
    ...
    switch(currency)
    case EUR: this.amount = round(amount, 2)
    case USD: this.amount = round(amount, 2)
    case BTC: this.amount = round(amount, 8)
    ...

    View Slide

  19. Mixing currencies & precisions
    becomes impossible

    View Slide

  20. Also see:
    Time zone type safety

    View Slide

  21. Example:
    Data Matching
    Paying out money based on
    usage of content
    Determine ownership by
    matching data from various
    sources

    View Slide

  22. Data sources:
    Own research by employees
    Off shore data cleaning
    Public wiki-style
    Public but curated
    Private, paid
    Direct submissions from individuals
    Agencies representing owners

    View Slide

  23. Lots of incentives for fraud

    View Slide

  24. Is this our Core Domain?
    ✗ It's just technical data imports




    View Slide

  25. Is this our Core Domain?
    ✗ It's just technical data imports
    ✗ Business is not interested



    View Slide

  26. Is this our Core Domain?
    ✗ It's just technical data imports
    ✗ Business is not interested
    ✔ Money changing hands


    View Slide

  27. Is this our Core Domain?
    ✗ It's just technical data imports
    ✗ Business is not interested
    ✔ Money changing hands
    ✔ The code you keep secret

    View Slide

  28. Is this our Core Domain?
    ✗ It's just technical data imports
    ✗ Business is not interested
    ✔ Money changing hands
    ✔ The code you keep secret
    ✔ Oldest code in the system

    View Slide

  29. Event Storming

    View Slide

  30. Temporality
    The quality of data
    changes over time,
    based on who changes it

    View Slide

  31. Missing concept:
    Matching Data
    =>
    ?

    View Slide

  32. Missing concept:
    Matching Data
    =>
    Earning Trust

    View Slide

  33. What if Trust was a tangible thing
    in our domain model?

    View Slide

  34. Trust as a Value Object

    View Slide

  35. Trust can be passed around

    View Slide

  36. Trust attracts behaviour

    View Slide

  37. "Trust" adopted into Ubiquitous
    Language

    View Slide

  38. The business started getting
    interested and involved

    View Slide

  39. Polymorphic strategies for changing Trust
    Event-based workflows

    View Slide

  40. 0 <-> 5 <-> 10

    View Slide

  41. A Trust Arithmetic
    Invented by the business
    0 <-> 5 <-> 10
    Group
    (closure, associativity, identity, invertibility)

    View Slide

  42. Metaphors as objects

    View Slide

  43. «His people are completely literal.
    Metaphors go over his head.»

    View Slide

  44. «Nothing goes over my head.
    My reflexes are too fast,
    I would catch it.»

    View Slide

  45. Example:
    Phone call bill rating

    View Slide

  46. Price per minute, price after the 60th minute
    Bundles: Credit minutes, lower rates
    Subscriptions: recurring bundles
    Promotions and incentives
    End of month transfers, expiries
    Flexible rating strategies in different markets

    View Slide

  47. "It's just an algorithm"

    View Slide

  48. Missing Metaphor:
    Buckets

    View Slide

  49. View Slide

  50. View Slide

  51. Mental Model
    ~
    Visual Model
    ~
    Implementation Model

    View Slide

  52. New opportunity:
    Long lead time to change pricing
    =>
    Lively experimentation with pricing

    View Slide

  53. «Habitable software (...)
    enables people to understand
    its construction and intentions
    and to change it
    comfortably and confidently.»3
    Programmers are not the only
    ones inhabiting our systems
    3 "Patterns of Software", Richard P. Gabriel, 1996

    View Slide

  54. Example:
    Bulb Management
    System
    Context Mapping

    View Slide

  55. Blub
    Management
    System

    View Slide

  56. Blub
    Management
    System
    Germanic
    countries
    Benelux
    +10 more
    regions
    UK &
    Ireland
    France

    View Slide

  57. Blub
    Management
    System
    Germanic
    countries
    Benelux
    +10 more
    regions
    UK &
    Ireland
    France
    changes

    View Slide

  58. Blub
    Management
    System
    Germanic
    countries
    Benelux
    +10 more
    regions
    UK &
    Ireland
    France
    changes
    breaks

    View Slide

  59. Blub
    Management
    System
    Germanic
    countries
    Benelux
    +10 more
    regions
    UK &
    Ireland
    France
    Customers Customers Customers
    Customers Customers
    changes
    breaks
    requests

    View Slide

  60. Blub
    Management
    System
    Germanic
    countries
    Benelux
    +10 more
    regions
    UK &
    Ireland
    France
    Customers Customers Customers
    Customers Customers
    CEO
    Senior
    Manager
    Middle
    Manager
    reports to
    changes
    breaks
    requests

    View Slide

  61. Blub
    Management
    System
    Germanic
    countries
    Benelux
    +10 more
    regions
    UK &
    Ireland
    France
    Customers Customers Customers
    Customers Customers
    CEO
    Senior
    Manager
    Middle
    Manager
    reports to
    changes
    breaks
    requests

    View Slide

  62. «Any organization
    that designs a system
    will produce a design
    whose structure is a copy
    of the organization's
    communication structure.»5
    5 "How Do Committees Invent?", Melvin E. Conway, 1968

    View Slide

  63. Heuristic:
    Follow the Money

    View Slide

  64. Blub
    Management
    System
    Germanic
    countries
    Benelux
    +10 more
    regions
    UK &
    Ireland
    France
    Customers Customers Customers
    Customers Customers
    CEO
    Senior
    Manager
    Middle
    Manager
    revenue
    costs

    View Slide

  65. Blub
    Management
    System
    Germanic
    countries
    Benelux
    +10 more
    regions
    UK &
    Ireland
    France
    Customers Customers Customers
    Customers Customers
    CEO
    Senior
    Manager
    Middle
    Manager
    revenue
    costs

    View Slide

  66. Blub
    Management
    System
    Germanic
    countries
    Benelux
    +10 more
    regions
    UK &
    Ireland
    France
    Customers Customers Customers
    Customers Customers
    CEO
    Senior
    Manager
    Middle
    Manager
    Blub
    Algorithms
    revenue
    costs

    View Slide

  67. Blub
    Management
    System
    Germanic
    countries
    Benelux
    +10 more
    regions
    UK &
    Ireland
    France
    Customers Customers Customers
    Customers Customers
    CEO
    Senior
    Manager
    Middle
    Manager
    Blub
    Algorithms

    View Slide

  68. Observations on
    better software design

    View Slide

  69. Obsess over language

    View Slide

  70. Visualise different models
    structural
    temporal
    spatial
    organisational

    View Slide

  71. Grasp the underlying problem
    domain

    View Slide

  72. Use metaphor

    View Slide

  73. Follow the money

    View Slide

  74. Make unspoken concepts explicit

    View Slide

  75. Thank you —
    @mathiasverraes
    verraes.net
    dddeurope.com
    bit.ly/bddx-november

    View Slide