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

La simplicité comme moyen d'être performant, résilient et de réduire le Time To Market.

La simplicité comme moyen d'être performant, résilient et de réduire le Time To Market.

Il y a 1 an et demi, la Société Générale a décidé de construire un nouveau service de vente électronique de nos produits financiers. Les contraintes étaient claires : "le système sera performant, auditable, résilient et développé de manière à avoir un Time To Market court". Une seule solution s'imposait à nous : faire simple, très simple !
Ainsi à travers cette présentation, nous vous raconterons notre quête de simplicité. Vous verrez ainsi que notre stack technique ne contient quasiment aucun framework, juste quelques bibliothèques utiles ou indispensables. Notre code se structure autour de quelques principes : l'Event Sourcing, un peu de Domain Driven Design et une discipline de fer en matière de qualité et de tests automatisés (BDD for the win!).

Marie-Laure Thuret

June 03, 2015
Tweet

More Decks by Marie-Laure Thuret

Other Decks in Programming

Transcript

  1. Construire le SI de demain
    REX Société Générale
    La simplicité comme moyen d'être
    performant, résilient
    et de réduire le Time To Market

    View Slide

  2. Marie-Laure
    Thuret
    @mlthuret
    Développeur
    chez
    Clément
    Héliou
    @c_heliou
    Développeur
    chez
    Thierry
    Abaléa
    @ThierryAbalea
    Tech Lead
    à la
    Société Générale

    View Slide

  3. View Slide

  4. View Slide

  5. View Slide

  6. View Slide

  7. Palladium

    View Slide

  8. View Slide

  9. Commodity
    Trading Company

    View Slide

  10. Today
    Hedging
    Commodity
    Trading Company

    View Slide

  11. Commodity
    Trading Company
    Few Months Later
    Hedging
    Physical Delivery

    View Slide

  12. View Slide

  13. Sales Person
    Customer Trader
    Booking
    Exchanges

    View Slide

  14. Automatize
    the
    processus

    View Slide

  15. Orchestrator
    Customer Exchanges
    Pricer
    Booking
    Hedger
    Trading Limit
    Margin

    View Slide

  16. View Slide

  17. The Constraints
    Reliability / Resilience Performance
    Productivity / Time To Market

    View Slide

  18. Our Solution
    Simplicity

    View Slide

  19. Simple ≠ Easy

    View Slide

  20. Choices are
    business-oriented

    View Slide

  21. Functional
    and Code
    Reduce the impedance between
    Our Goal

    View Slide

  22. Orchestration
    Let’s take an example with
    our main component

    View Slide

  23. View Slide

  24. View Slide

  25. View Slide

  26. Event Sourcing

    View Slide

  27. « Capture all changes to an
    application state as a
    sequence of events »
    Martin Fowler

    View Slide

  28. Date Money Out Money In
    2015/05/14 100 €
    2015/05/14 -20 €
    2015/05/16 -30 €
    2015/05/24 380 €
    2015/06/01 -70 €
    Total -120 € 480 €
    Balance 360 €

    View Slide

  29. WithdrawalPerformed
    accountId: 9387
    amount: 30€
    BankAccount
    id: 9387
    balance: 0€
    WithdrawalPerformed
    accountId: 9387
    amount: 20€
    DepositPerformed
    accountId: 9387
    amount: 100€
    BankAccount
    id: 9387
    balance: 50€
    BankAccount
    id: 9387
    balance: 100€
    BankAccount
    id: 9387
    balance: 80€
    Inspired by B. Reitzammer & J. Seitz - http://ookami86.github.io/event-sourcing-in-practice
    Apply to
    Apply to
    Apply to
    Produces
    Produces
    Produces

    View Slide

  30. J. Chassaing - http://thinkbeforecoding.com/post/2014/01/04/Event-Sourcing.-Draw-it

    View Slide

  31. BankAccount
    id: 9387
    balance: 0€
    WithdrawalPerformed
    accountId: 9387
    amount: 20€
    DepositPerformed
    accountId: 9387
    amount: 100€
    BankAccount
    id: 9387
    balance: 100€
    Bug
    Inspired by B. Reitzammer & J. Seitz - http://ookami86.github.io/event-sourcing-in-practice
    Apply to
    Apply to
    Produces
    Produces

    View Slide

  32. WithdrawalPerformed
    accountId: 9387
    amount: 30€
    BankAccount
    id: 9387
    balance: 0€
    WithdrawalPerformed
    accountId: 9387
    amount: 20€
    DepositPerformed
    accountId: 9387
    amount: 100€
    BankAccount
    id: 9387
    balance: 100€
    BankAccount
    id: 9387
    balance: 70€
    Inspired by B. Reitzammer & J. Seitz - http://ookami86.github.io/event-sourcing-in-practice
    Apply to
    Apply to
    Produces
    Produces

    View Slide

  33. Domain Driven Design

    View Slide

  34. «
    DDD is about designing
    software based on models
    of the underlying
    (business) domain »
    Martin Fowler

    View Slide

  35. Ubiquitous
    Language
    Repository
    Aggregate Root
    Entity
    Value Object

    View Slide

  36. Durable
    business model
    Extensibility
    Clean Architecture
    Solid Responsibility Segregation

    View Slide

  37. Using Event Sourcing
    and DDD concepts in
    Multiplus

    View Slide

  38. Multiplus
    Business
    Logic
    ReceiveQuote
    {command}
    QuoteReceived
    {event}
    QuoteForwarded
    {event}
    Customer
    Event Bus
    QuoteForwardedHandler
    {handler}
    Quote
    Requesting Quoting
    QuoteReceived
    {event}
    QuoteReceived
    {event}
    ForwardQuote
    {action}

    View Slide

  39. Transaction
    {aggregate root}
    Pricing
    {entity}
    Execution
    {entity}
    Orchestration
    {entity}
    ReceiveQuote
    {command/value object}
    quoteRequestId: 4563
    price: 100€
    QuoteReceived
    {event/value object}
    accountId: 4563
    price: 110€
    - Multiplus Business Logic -

    View Slide

  40. What we’ve
    learned

    View Slide

  41. Be
    aware of
    Command
    Sourcing

    View Slide

  42. Multiplus
    Business
    Logic
    ReceiveQuote
    {command}
    quoteRequestId: 4563
    price: 100€
    QuoteForwarded
    {event}
    accountId: 4563
    price: 101€
    Multiplus
    Business
    Logic
    ReceiveQuote
    {command}
    quoteRequestId: 4563
    price: 100€
    QuoteForwarded
    {event}
    accountId: 4563
    price: 102€
    2015/06/01 Margin: 1%
    2015/11/01 Margin: 2%

    View Slide

  43. View Slide

  44. Multiplus
    Business
    Logic
    ReceiveQuote
    {command}
    QuoteForwarded
    {event}
    Customer
    Event Bus
    QuoteForwardedHandler
    {handler}
    {Quote n° 65746}
    {Quote n° 65746} ??
    QuoteReceived
    {event}
    ForwardQuote
    {action}

    View Slide

  45. Multiplus
    Business
    Logic
    ReceiveQuote
    {command}
    QuoteForwarded
    {event}
    Customer
    Event Bus
    QuoteForwardedHandler
    {handler}
    Customer
    gateway
    {Quote n° 65746}
    {Quote n° 65746}
    QuoteReceived
    {event}
    ForwardQuote
    {action}

    View Slide

  46. Store the events
    produced by the
    Decide function

    View Slide

  47. Multiplus
    Business
    Logic
    ReceiveQuote
    {command}
    quoteRequestId: 4563
    price: 100€
    QuoteForwarded
    {event}
    accountId: 4563
    price: 101€
    Multiplus
    Business
    Logic
    2015/06/01 Margin: 1%
    2015/11/01 Margin: 2%
    QuoteForwarded
    {event}
    accountId: 4563
    price: 101€

    View Slide

  48. Multiplus
    Business
    Logic
    ReceiveQuote
    {command}
    QuoteForwarded
    {event}
    Customer
    Event Bus
    QuoteForwardedHandler
    {handler}
    QuoteReceived
    {event}
    ForwardQuote
    {action}

    View Slide

  49. It’s all in the past !

    View Slide

  50. Date Money Out Money In
    2015/05/14 100 €
    2015/05/14 -20 €
    2015/05/16 -30 €
    2015/05/24 30 €
    2015/06/01 -70 €
    Total -120 € 130 €
    Balance 10 €

    View Slide

  51. Behavior Driven
    Development
    Conversation
    Collaboration
    Specifications By Examples
    Three Amigos
    Automation
    Ubiquitous Language

    View Slide

  52. deliver
    the
    right
    software

    View Slide

  53. Your
    documentation
    will become
    alive

    View Slide

  54. you
    will
    new comers
    thank

    View Slide

  55. you
    will
    new comers
    thank
    … but you’ll enjoy it too !

    View Slide

  56. warning

    View Slide

  57. doing BDD right
    easy
    is not

    View Slide

  58. BDD
    Common Issues
    Business and developper
    faces collaboration difficulties
    Mess with the
    scenario writing
    Automation Nightmare

    View Slide

  59. BDD
    Common Issues
    Business and developper
    faces collaboration difficulties
    Mess with the
    scenario writing
    Automation Nightmare

    View Slide

  60. our
    complex
    application
    are
    often

    View Slide

  61. we tend to let
    everywhere
    business rules
    being dispatch

    View Slide

  62. … making them
    hard to test

    View Slide

  63. Hexagonal
    Architecture
    the onion architecture
    the clean architecture
    ports and adapters

    View Slide

  64. domain
    adapters
    Port
    (
    inbound)
    Port
    (
    outbound)
    Web
    Message Queue
    Database

    View Slide

  65. Advantages
    Testability Flexibility
    Business Centric

    View Slide

  66. domain driven
    app structure

    View Slide

  67. that’s not
    enough !

    View Slide

  68. use different
    granularity
    business scenarios
    when expressing your
    levels

    View Slide

  69. Given a quantity value of 1000 in G
    When the quantity is converted in OZ
    Then the converted quantity is 32.1507 OZ
    Given a quote request with a way BUY
    And the credit check request has been sent
    When the credit check response is in error
    Then the pricer does not receive a quote request
    And the platform quote status is REJECTED
    Given an authorized product type
    When the customer sends the rfs
    Then the pricer receives the rfs
    When the pricer sends a quote
    Then the customer receives the quote
    Workflow
    Feature
    Unit

    View Slide

  70. « l’enfer c’est les
    autres »
    Jean-Paul Sartre

    View Slide

  71. at
    any time
    business validation

    View Slide

  72. View Slide

  73. steroids
    integration testing
    on

    View Slide

  74. care about
    the contract
    between your app and another

    View Slide

  75. avoid
    accidental
    complexity

    View Slide

  76. there’s always
    implicit
    a schema
    even if it’s

    View Slide

  77. Hexagonal
    Architecture
    DDD
    Event Sourcing
    BDD
    State Machine

    View Slide

  78. Hexagonal
    Architecture
    Java
    DDD
    Event Sourcing
    BDD
    State Machine

    View Slide

  79. Hexagonal
    Architecture
    Dagger
    Java
    DDD
    Event Sourcing
    BDD
    State Machine

    View Slide

  80. Hexagonal
    Architecture
    Dagger
    Java
    Guava
    DDD
    Event Sourcing
    BDD
    State Machine

    View Slide

  81. Our architecture
    is easy to deploy !

    View Slide

  82. Simple

    View Slide

  83. Simple
    No More Technologies Than Required

    View Slide

  84. Simple
    No More Technologies Than Required
    Business Centric

    View Slide

  85. Simple
    No More Technologies Than Required
    Business Centric
    Code Understanding is Key

    View Slide

  86. Simple
    No More Technologies Than Required
    Business Centric
    Courage
    Code Understanding is Key

    View Slide

  87. Any Questions ?

    View Slide