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

Discovering unknown with EventStorming ConFoo

Discovering unknown with EventStorming ConFoo

Mariusz Gil

March 14, 2019
Tweet

More Decks by Mariusz Gil

Other Decks in Programming

Transcript

  1. Mariusz Gil
    DISCOVERING UNKNOWN WITH
    @mariuszgil

    View Slide

  2. View Slide

  3. https://www.tripled.io/img/DDD-books.jpg

    View Slide

  4. CAPTURE
    The knowledge
    @mariuszgil

    View Slide

  5. Embed
    Into code
    @mariuszgil

    View Slide

  6. Protect
    From the world
    @mariuszgil

    View Slide

  7. The critical complexity
    of most software projects is in
    understanding the domain itself
    Eric Evans
    @mariuszgil

    View Slide

  8. Given…
    when…
    then…
    @mariuszgil

    View Slide

  9. Initial idea

    View Slide

  10. Reality

    View Slide

  11. View Slide

  12. View Slide

  13. Meet&
    tELL your STORY
    @mariuszgil

    View Slide

  14. View Slide

  15. View Slide

  16. @mariuszgil

    View Slide

  17. @mariuszgil

    View Slide

  18. Reservation
    requested
    @mariuszgil

    View Slide

  19. Reservation
    requested
    Reservation
    accepted
    @mariuszgil

    View Slide

  20. Reservation
    requested
    Reservation
    accepted
    Availability
    and Limits
    checked
    @mariuszgil

    View Slide

  21. Reservation
    requested
    Reservation
    accepted
    Availability
    and Limits
    checked
    @mariuszgil

    View Slide

  22. Reservation
    requested
    Reservation
    accepted
    Availability
    and Limits
    checked
    @mariuszgil

    View Slide

  23. Reservation
    requested
    Reservation
    accepted
    Availability
    and Limits
    checked
    customer
    @mariuszgil

    View Slide

  24. Reservation
    requested
    Reservation
    accepted
    Availability
    and Limits
    checked
    customer
    Reservation
    rejected
    How to handle
    rejections?
    @mariuszgil

    View Slide

  25. Reservation
    requested
    Reservation
    accepted
    Availability
    and Limits
    checked
    customer
    Reservation
    rejected
    How to handle
    rejections?
    Similar offer
    Proposed
    @mariuszgil

    View Slide

  26. Reservation
    requested
    Reservation
    accepted
    Availability
    and Limits
    checked
    customer
    Reservation
    rejected
    How to handle
    rejections?
    Similar offer
    Proposed
    agent
    @mariuszgil

    View Slide

  27. Airline ticket
    Api gateway
    Reservation
    requested
    Reservation
    accepted
    Availability
    and Limits
    checked
    customer
    Reservation
    rejected
    How to handle
    rejections?
    Similar offer
    Proposed
    agent
    @mariuszgil

    View Slide

  28. Airline ticket
    Api gateway
    Reservation
    requested
    Availability
    and Limits
    checked
    customer
    Reservation
    rejected
    How to handle
    rejections?
    Similar offer
    Proposed
    agent
    Email gateway
    Reservation
    accepted
    @mariuszgil

    View Slide

  29. Airline ticket
    Api gateway
    Reservation
    requested
    Availability
    and Limits
    checked
    customer
    Reservation
    rejected
    How to handle
    rejections?
    Similar offer
    Proposed
    agent
    Email gateway
    Confirmation
    Delivered
    Reservation
    accepted
    @mariuszgil

    View Slide

  30. Airline ticket
    Api gateway
    Reservation
    requested
    Availability
    and Limits
    checked
    customer
    Reservation
    rejected
    How to handle
    rejections?
    Similar offer
    Proposed
    agent
    Email gateway
    Confirmation
    Delivered
    Reservation
    accepted
    $
    $
    @mariuszgil

    View Slide

  31. Airline ticket
    Api gateway
    Reservation
    requested
    Availability
    and Limits
    checked
    customer
    Reservation
    rejected
    How to handle
    rejections?
    Similar offer
    Proposed
    agent
    Email gateway
    Confirmation
    Delivered
    Reservation
    accepted
    $
    $
    How to
    handle service
    Downtimes?
    @mariuszgil

    View Slide

  32. Airline ticket
    Api gateway
    Reservation
    requested
    Availability
    and Limits
    checked
    customer
    Reservation
    rejected
    How to handle
    rejections?
    Similar offer
    Proposed
    agent
    Email gateway
    Confirmation
    Delivered
    Reservation
    accepted
    $
    $
    How to
    handle service
    Downtimes?
    Some customers
    Have phones
    Only!
    @mariuszgil

    View Slide

  33. View Slide

  34. View Slide

  35. View Slide

  36. View Slide

  37. View Slide

  38. View Slide

  39. View Slide

  40. View Slide

  41. Bad decisions
    Cost a lot…
    @mariuszgil

    View Slide

  42. View Slide

  43. View Slide

  44. View Slide

  45. View Slide

  46. View Slide

  47. View Slide

  48. It’s DEVELoper (mis)understanding
    Not expert knowledge
    That get’s released in production
    Alberto Brandolini
    @mariuszgil

    View Slide

  49. Big picture
    Event storming
    @mariuszgil

    View Slide

  50. Design level
    Event storming
    @mariuszgil

    View Slide

  51. Aggregate
    Event
    Actor
    Command /
    Decision
    Read model
    External
    System
    Policy
    @mariuszgil
    Command
    Query

    View Slide

  52. @mariuszgil
    https://docs.axoniq.io/reference-guide/v/3.3/part-i-getting-started/architecture-overview

    View Slide

  53. Payment
    Registered
    Loyalty
    points
    registered
    Loyalty
    points
    calculated
    Upgrade
    limits
    reached
    Account
    upgraded to
    higher
    status
    @mariuszgil

    View Slide

  54. Payment
    Registered
    Loyalty
    points
    registered
    Loyalty
    points
    calculated
    Upgrade
    limits
    reached
    Account
    upgraded to
    higher
    status
    Register
    loyalty
    points
    @mariuszgil

    View Slide

  55. Payment
    Registered
    Loyalty
    points
    registered
    Loyalty
    points
    calculated
    Upgrade
    limits
    reached
    Account
    Status
    upgraded
    Register
    loyalty
    points
    Upgrade
    account
    status
    @mariuszgil

    View Slide

  56. Payment
    Registered
    Loyalty
    points
    registered
    Loyalty
    points
    calculated
    Upgrade
    limits
    reached
    Account
    Status
    upgraded
    Register
    loyalty
    points
    Upgrade
    account
    status
    required
    points
    Levels
    Account
    upgrading
    policy
    @mariuszgil

    View Slide

  57. Payment
    Registered
    Loyalty
    points
    registered
    Loyalty
    points
    calculated
    Upgrade
    limits
    reached
    Account
    Status
    upgraded
    Register
    loyalty
    points
    Upgrade
    account
    status
    required
    points
    Levels
    Account
    upgrading
    policy
    Reservations
    and
    payments
    history
    c.service
    @mariuszgil

    View Slide

  58. Payment
    Registered
    Loyalty
    points
    calculated
    Upgrade
    limits
    reached
    Account
    Status
    upgraded
    Upgrade
    account
    status
    required
    points
    Levels
    Account
    upgrading
    policy
    Loyalty account
    Loyalty
    points
    registered
    Register
    loyalty
    points
    Reservations
    and
    payments
    history
    c.service
    @mariuszgil

    View Slide

  59. Payment
    Registered
    Loyalty
    points
    calculated
    Upgrade
    limits
    reached
    Account
    Status
    upgraded
    Upgrade
    account
    status
    required
    points
    Levels
    Account
    upgrading
    policy
    Loyalty account
    Loyalty
    points
    registered
    Register
    loyalty
    points
    Reservations
    and
    payments
    history
    c.service
    @mariuszgil

    View Slide

  60. Outcomes
    @mariuszgil

    View Slide

  61. Possible
    implementation
    Solution
    @mariuszgil
    There are many of them!!!!!!

    View Slide

  62. business
    domain logic
    application logic
    infrastructure

    View Slide

  63. business logic
    application logic
    infrastructure

    View Slide

  64. business logic
    application logic
    infrastructure
    aggregate
    Event publishing
    command domain event

    View Slide

  65. @Entity // Mark this aggregate as a JPA Entity
    public class MyAggregate {
    @Id
    private String id;
    // fields containing state...
    @CommandHandler
    public MyAggregate(CreateMyAggregateCommand command) {
    // ... update state
    apply(new MyAggregateCreatedEvent(...));
    }
    // constructor needed by JPA
    protected MyAggregate() {
    }
    }
    Event
    Command /
    Decision

    View Slide

  66. domain event
    domain event
    business logic
    application logic
    infrastructure
    domain event
    aggregate
    domain event
    event sourcing

    View Slide

  67. public class MyAggregateRoot {
    @AggregateIdentifier
    private String aggregateIdentifier;
    // fields containing state...
    @CommandHandler
    public MyAggregateRoot(CreateMyAggregate cmd) {
    apply(new MyAggregateCreatedEvent(cmd.getId()));
    }
    // constructor needed for reconstruction
    protected MyAggregateRoot() {
    }
    @EventSourcingHandler
    private void handleMyAggregateCreatedEvent(MyAggregateCreatedEvent event) {
    // make sure identifier is always initialized properly
    this.aggregateIdentifier = event.getMyAggregateIdentifier();
    // ... update state
    }
    }
    Aggregate

    View Slide

  68. domain event
    domain event
    domain event
    domain event
    business logic
    application logic
    infrastructure
    domain event
    domain event
    command
    domain event
    policy
    process managers

    View Slide

  69. business logic
    application logic
    infrastructure
    domain event
    command
    saga
    domain event
    command
    domain event
    Compensate
    command
    policy
    policy

    View Slide

  70. public class OrderManagementSaga {
    private boolean paid = false;
    private boolean delivered = false;
    @Inject
    private transient CommandGateway commandGateway;
    @StartSaga
    @SagaEventHandler(associationProperty = "orderId")
    public void handle(OrderCreatedEvent event) {
    // client generated identifiers
    ShippingId shipmentId = createShipmentId();
    InvoiceId invoiceId = createInvoiceId();
    // associate the Saga with these values, before sending the commands
    SagaLifecycle.associateWith("shipmentId", shipmentId);
    SagaLifecycle.associateWith("invoiceId", invoiceId);
    // send the commands
    commandGateway.send(new PrepareShippingCommand(...));
    commandGateway.send(new CreateInvoiceCommand(...));
    }
    @SagaEventHandler(associationProperty = "shipmentId")
    public void handle(ShippingArrivedEvent event) {
    delivered = true;
    if (paid) { SagaLifecycle.end(); }
    }
    @SagaEventHandler(associationProperty = "invoiceId")
    public void handle(InvoicePaidEvent event) {
    paid = true;
    if (delivered) { SagaLifecycle.end(); }
    }
    // ...
    }
    Reactive
    Policy

    View Slide

  71. read model
    business logic
    application logic
    infrastructure
    read models
    domain event
    domain event
    domain event
    domain event
    read model
    read model
    read model

    View Slide

  72. business logic
    application logic
    infrastructure

    View Slide

  73. business logic
    application logic
    infrastructure

    View Slide

  74. business logic
    application logic
    infrastructure
    BUS
    Event

    View Slide

  75. Event
    Command /
    Decision
    Event
    Event Aggregate

    View Slide

  76. public class MyCommandComponentTest {
    private FixtureConfiguration fixture;
    @Before
    public void setUp() {
    fixture = new AggregateTestFixture<>(MyAggregate.class);
    }
    @Test
    public void testFirstFixture() {
    fixture.given(new MyEvent(1))
    .when(new TestCommand())
    .expectSuccessfulHandlerExecution()
    .expectEvents(new MyEvent(2));
    /*
    }
    }
    Event
    Command /
    Decision
    Event
    Event Aggregate
    Given When Then

    View Slide

  77. Command /
    Decision
    Read model
    Event
    Event
    Given When Then

    View Slide

  78. Event
    Command /
    Decision
    Aggregate
    Read model
    Given When Then
    Event

    View Slide

  79. DDD is not
    for you?
    @mariuszgil

    View Slide

  80. Event
    Command /
    Decision
    Aggregate Read model
    Reactive
    Policy

    View Slide

  81. Event
    Command /
    Decision
    Aggregate Read model
    Reactive
    Policy
    Record
    Inserted /
    Changed /
    Deleted
    Insert /
    Update /
    Delete /
    Truncate /

    Record /
    Table
    Select /
    View
    Trigger /
    Procedure

    View Slide

  82. Takeaways
    @mariuszgil

    View Slide

  83. Big Picture
    Events
    Processes & Flows
    Hot Spots
    Systems
    Boundaries
    People
    @mariuszgil

    View Slide

  84. Process Modeling
    Commands
    Policies
    Read Models
    Value Propositions
    Personas
    Metrics & Alerts
    @mariuszgil

    View Slide

  85. Software Design
    Aggregates
    Policies
    Reactive Logic
    Read Models
    @mariuszgil

    View Slide

  86. Communication!
    @mariuszgil

    View Slide

  87. Building common
    understanding
    @mariuszgil

    View Slide

  88. From production session

    View Slide

  89. From production session

    View Slide

  90. From alberto bandolino workshop

    View Slide

  91. From production session

    View Slide

  92. Software development is learning process
    Working code is a side effect
    Alberto Brandolini
    @mariuszgil

    View Slide

  93. View Slide

  94. What’s next?
    @mariuszgil

    View Slide

  95. View Slide

  96. View Slide

  97. View Slide

  98. THANK YOU!
    @mariuszgil

    View Slide