Event Sourcing, or Why ActiveRecord Must Die

Event Sourcing, or Why ActiveRecord Must Die

Much has been said about the dangers with ActiveRecord, but the advice is usually limited to avoiding callbacks or not building God models. We still use it because there hasn't been a viable alternative. It is not actually a trait unique to ActiveRecord that makes it dangerous, however--it's because it's an ORM, and all ORMs must die.

With Event Sourcing, we can build Ruby applications that are simple, scalable, extensible, and elegant without ActiveRecord or any other ORM anywhere in sight. We also get a free time machine as a bonus, and we'll find out that Event Sourcing is a lot older than we might think.

I gave this presentation at RubyConf AU 2016 in Gold Coast, QLD.

If you found this interesting, you can find my more recent (and way more in-depth) talk on Event Sourcing here: https://speakerdeck.com/vonconrad/an-in-depth-look-at-event-sourcing-with-cqrs

C00089fa70bfc238069005c7b4fbd15f?s=128

Sebastian von Conrad

February 11, 2016
Tweet

Transcript

  1. 2.
  2. 22.
  3. 28.
  4. 46.

    How can you know for sure that the data is

    never going to be relevant?
  5. 69.

    (And no amount of fluff at the beginning of a

    talk can fix that discomfort.)
  6. 70.

    Why should I have to go out of my way

    not to lose what’s most important?
  7. 82.

    This is a new way to build software and it

    will change our industry.
  8. 87.

    ActiveRecord #<User id: 216, first_name: “John”, last_name: “Reed” ...> +

    --- + ---------- + --------- + --- + | id | first_name | last_name | ... | | --- | ---------- | --------- | --- | | 216 | John | Reed | ... | | ... | ... | ... | ... | + --- + ---------- + --------- + --- +
  9. 89.

    ActiveRecord #<User id: 216, first_name: “John”, last_name: “Hill”, ...> +

    --- + ---------- + --------- + --- + | id | first_name | last_name | ... | | --- | ---------- | --------- | --- | | 216 | John | Hill | ... | | ... | ... | ... | ... | + --- + ---------- + --------- + --- +
  10. 93.

    Event Sourcing #<User id: 216, first_name: “John”, last_name: “Reed”, ...>

    { id: 216, type: “user_signed_up”, body: { first_name: “John”, last_name: “Reed” } }
  11. 95.

    Event Sourcing #<User id: 216, first_name: “John”, last_name: “Hill”, ...>

    { type: “user_sign_up”, body: { first_name: “John”, last_name: “Reed” } }, { type: “user_changed_name”, body: { last_name: “Hill” } }
  12. 108.
  13. 111.

    + ---------------- + -------- + ------- + | | Debit

    | Credit | | ---------------- | ------- | -------- | | ... | | | | ---------------- | --------| -------- | | Total balance | | $405.00 | + ---------------- + ------- + -------- +
  14. 114.

    + ---------------- + -------- + ------- + | | Debit

    | Credit | | ---------------- | ------- | -------- | | Training stipend | | $1000.00 | | RubyConf ticket | $595.00 | | | ---------------- | --------| -------- | | Total balance | | $405.00 | + ---------------- + ------- + -------- +
  15. 131.

    Why are we so caught up with the idea of

    mapping object state to database tables?
  16. 143.
  17. 145.