Top Banner
Events are not just for notifications Greg Young Qcon London
26

Greg Young Qcon London - GOTO Conferencegotocon.com/dl/qcon-london-2011/slides/GregYoung_Events... · 2011. 3. 15. · Not allowed to take money out of an overdrawn account Given

Feb 02, 2021

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • Events are not just for notificationsGreg Young Qcon London

  • Agenda

    Event StorageTesting With EventsVersioningPerformanceTraveling Through Space and TimeLet Everyone Run to Airport to Catch Flights

  • Purchase Order

    Line Items (n)

    Shipping Information

  • Cart Created

    Line Item Added

    Address Added

    Line Item Added

    Line Item Added

  • Cart Created

    Line Item Added

    Address Added

    Line Item Added

    Line Item Added

    Cart Object

  • Cart Created

    Line Item Added

    Address Added

    Line Item Added

    Line Item Added

    Line Item Removed

    Address Added

  • Cart Created

    Line Item Added

    Address Added

    Line Item Added

    Line Item Added

    New Cart Object(Looks totally

    different)

  • 6

    5

    4

    3

    2

    1

    7

  • 5

    snap

    4

    3

    2

    1

    6

  • Base { public IEnumerable GetUncommittedChanges() { return _changes; }

    public void MarkChangesAsCommitted() { _changes.Clear(); }

    public void LoadsFromHistory(IEnumerable history) { foreach (var e in history) ApplyChange(e, false); }}

  • Base { protected void ApplyChange(Event @event) { ApplyChange(@event, true); }

    private void ApplyChange(Event @event, bool isNew) { this.AsDynamic().Apply(@event); if(isNew) _changes.Add(@event); }}

  • private void Apply(InventoryItemDeactivated e) { _activated = false; }

    public void Deactivate() { if(!_activated) throw new InvalidOperationException("already deactivated"); ApplyChange(new InventoryItemDeactivated(_id)); }

  • Derived { protected void ApplyChange(Event @event) { ApplyChange(@event, true); }

    private void ApplyChange(Event @event, bool isNew) { this.AsDynamic().Apply(@event); if(isNew) _changes.Add(@event); }}

  • Overdraw attempts are rejected

    Given An account with $100

    When A debit is requested for $101 Then An InsufficientBalanceException is thrown

  • Overdraw attempts are rejected

    Given An account was created. An initial deposit was made for $100

    When A debit is requested for $101 Then An InsufficientBalanceException is thrown

  • Overdraw attempts are rejected

    Given A series of events

    When A command Then A series of events

  • Not allowed to take money out of an overdrawn account

    Given An account was created. An initial deposit was made for $100 $100 was withdrawn

    When A debit is requested for $20 Then An InsufficientBalanceException is thrown

  • Traveling Through Time.

  • Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24Slide 25Slide 26