Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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.

330627d5f564b710721236077903ed60?s=128

Mathias Verraes

November 10, 2016
Tweet

Transcript

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

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

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

  6. A healthy obsession with language

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

  9. Make the implicit explicit What are we really doing? What

    missing concepts can we identify? How can we bring them forward?
  10. Example:1 Money 1 http://verraes.net/2016/02/type-safety-and-money/

  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
  12. Testable != idiot-proof2 2 Typical idiots include future self

  13. * You may not want to use floats. "Patterns of

    Enterprise Application Architecture", Martin Fowler, 2002
  14. Constructor enforces decimals. Operations protect against wrong currencies.

  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
  16. PreciseMoney { round() : RoundedMoney { return new RoundedMoney(amount, currency)

    } ... } RoundedMoney { add(RoundedMoney other) : RoundedMoney {...} multiply(Float operand) : PreciseMoney {...} ... }
  17. None
  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) ...
  19. Mixing currencies & precisions becomes impossible

  20. Also see: Time zone type safety

  21. Example: Data Matching Paying out money based on usage of

    content Determine ownership by matching data from various sources
  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
  23. Lots of incentives for fraud

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

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

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

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

    imports ✗ Business is not interested ✔ Money changing hands ✔ The code you keep secret ⬜
  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
  29. Event Storming

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

    who changes it
  31. Missing concept: Matching Data => ?

  32. Missing concept: Matching Data => Earning Trust

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

    model?
  34. Trust as a Value Object

  35. Trust can be passed around

  36. Trust attracts behaviour

  37. "Trust" adopted into Ubiquitous Language

  38. The business started getting interested and involved

  39. Polymorphic strategies for changing Trust Event-based workflows

  40. 0 <-> 5 <-> 10

  41. A Trust Arithmetic Invented by the business 0 <-> 5

    <-> 10 Group (closure, associativity, identity, invertibility)
  42. Metaphors as objects

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

  44. «Nothing goes over my head. My reflexes are too fast,

    I would catch it.»
  45. Example: Phone call bill rating

  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
  47. "It's just an algorithm"

  48. Missing Metaphor: Buckets

  49. None
  50. None
  51. Mental Model ~ Visual Model ~ Implementation Model

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

    experimentation with pricing
  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
  54. Example: Bulb Management System Context Mapping

  55. Blub Management System

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

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

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

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

    & Ireland France Customers Customers Customers Customers Customers changes breaks requests
  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
  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
  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
  63. Heuristic: Follow the Money

  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
  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
  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
  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
  68. Observations on better software design

  69. Obsess over language

  70. Visualise different models structural temporal spatial organisational

  71. Grasp the underlying problem domain

  72. Use metaphor

  73. Follow the money

  74. Make unspoken concepts explicit

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