Download - Event Sourcing

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).