event sourcing

35
Herman Peeren 010PHP November 2014 Event Sourcing

Upload: herman-peeren

Post on 26-Jun-2015

338 views

Category:

Software


2 download

DESCRIPTION

Presentation November 13, 2014 at 010PHP, Rotterdam, http://www.meetup.com/010PHP/events/212147112/ about Event Sourcing: In many applications the current state is constantly updated, overwriting previous states. Information about the history is lost then. With Event Sourcing you store all events that have led to a change in application state. The current and previous states can always be reconstituted from the series of events that has been stored. That gives lots of possibilities. I gave an overview of the background of Event Sourcing, with a sidestep to some thoughts about 'identity'. Related concepts, like CQRS and other DDD-jargon, were explained and I briefly mentioned Functional Programming. After my talk we looked at Broadway, the open sourced project from Qandidate, that provides a PHP infrastructure for Event Sourcing and CQRS. FritsJan Bakker, one of the builders of Broadway, told something more about it and how they used Event Sourcing at Qandidate. ----- Summary of slides: * 2-3: while updating, history is lost * 4: an n:m relationship where info of the past was stored * 5-7: DDD-jargon: Aggregate and Aggregate Root * 8-10: Demeter's Law as applied to the Aggregate Root * 11-17: Event Sourcing, storing past events, like in accounting * 18-25: about identity (you are the realisation of changes) * 26: Functional Programming (same paradigm as ES) * 27-30: CQRS and the bigger picture * 31-33: Broadway * 34: Pool Request

TRANSCRIPT

Page 1: Event Sourcing

Herman Peeren010PHP

November 2014

Event Sourcing

Page 2: Event Sourcing

Update

Page 3: Event Sourcing

Update

Page 4: Event Sourcing

Entities - Relationships

Page 5: Event Sourcing

DDD-jargon: Aggregate

Aggregate: house of cooperating entities (consistency boundaries)

Page 6: Event Sourcing

DDD-jargon: Aggregate Root

Aggregate root: the entrance of the house, the interface to the outside world

Page 7: Event Sourcing

DDD-jargon: Aggregate Root

Aggregate protects its own invariants: keep your house clean

Page 8: Event Sourcing

Demeter’s Lawonly talk to your immediate friends

Page 9: Event Sourcing

Demeter’s LawCommand the dog, not the dog’s legs

Page 10: Event Sourcing

Demeter’s LawCommand the dog, not the dog’s legs

Page 11: Event Sourcing

Event Sourcing• you don’t store the state, • but the proces that caused the change

Page 12: Event Sourcing

Accounting: same principle• you don’t store the changed balance, • but the journal entries that caused the change

Page 13: Event Sourcing

Event Sourcing• you don’t add an item to a collection of jobs, • but you take or quit a job

Page 14: Event Sourcing

Event Sourcing• you don’t add an item to a collection of jobs, • but you hire or fire someone

Emphasis on the action, using words used in the domain, not on the data

Page 15: Event Sourcing

Event Store

Page 16: Event Sourcing

Event Store

Page 17: Event Sourcing

Event Sourcing

Page 18: Event Sourcing

EntityEquality is decided by its identity, not by its values

never too old to run

Page 19: Event Sourcing

Theseus’ship paradox

Page 20: Event Sourcing

Theseus’ship paradox

Page 21: Event Sourcing

Theseus’ship paradox

Page 22: Event Sourcing

Identity

Page 23: Event Sourcing

Identity

Page 24: Event Sourcing

Identity

Page 25: Event Sourcing

IdentityYou are who you were + the difference since then

Page 26: Event Sourcing

Functional ProgrammingData are what they were + the difference since then

Page 27: Event Sourcing

Event Sourcing & CQRSCQRS = Command Query Responsibility Segregation: separate Read & Write Model

Page 28: Event Sourcing

Event Sourcing & CQRS

FromtheAxonFrameworkdocumentation

Page 29: Event Sourcing

Event Sourcing & CQRS

Page 30: Event Sourcing

Event Sourcing+• lossles, extra read-models can always later be added• more verbs than data centric, closer to mental model and domain language

-• increased complexity when state is rarely updated

CQRS+• loosely coupled, specialised read & write side• scalability

-• more complexity when project is not complex or doesn’t need scaling

Page 31: Event Sourcing

Broadway

Page 32: Event Sourcing

Broadway: namespaces

Page 33: Event Sourcing

Broadway: examples

Other interesting PHP framework (less production-ready?): https://github.com/szjani/predaddy

Page 34: Event Sourcing

Pool RequestJoomlaWorldConference,Mexiconovember2014

Page 35: Event Sourcing

Thank you!

[email protected]

hermanpeeren.nl@HermanPeeren

November 13, 2014

Credits:Sorry! For this presentation I’ve used all kinds of images I collected from the web during the past months. I didn’t note down the various sources, so I cannot give credit to the owners of the images. I can only thank you all very much for making them available on the internet and I hope I did not violate your rights too much borrowing them. If you own the rights to an image used here, please let me know and I will mention it (or take the image out of these slides if you want to).