Skip to content
Snippets Groups Projects
Jan Kuchař's avatar
Jan Kuchař authored
64db7e6d
History

Event-Sourcing basic example app

Aim: learn basics of event sourcing pattern and its caveats.

This project builds on an example from the presentation from Mathias Verraes - Practical Event Sourcing.

Learning material of DDD (Domain Driven Design)

Bellow is learning material that I have used to dive into event DDD (and its implementations) deeper.

Strategic Design

I have put DDD in its own section because DDD is more an analysis process than a collection of structural patterns.

Case studies

Learning the Technical Stuff

This section describes how people are implementing their domains. Be careful. Always make sure you know why author of talk decided to do his thing that way.

Event Sourcing + CQRS

An alternative implementation of domain model persistence layer which stores a complete history of all events that happened in the domain in the past.

(The structural part of) DDD in PHP

Message Buses/libraries

Process Managers / Sagas (the same thing!)

Examples

Notes / TODOs

  • How to make a proper relation between Product and Basket?
    • Answer: Analyse bounded contexts. (probably in most domains use two separate AggregateRoots)
  • How to access product name when product-related event occurs - aggregate does not expose any state?! (should I access read model from write model?)
    • Answer: Access read side if needed or use heavy events.
  • If aggregate produces event but it does not change state in any way, should it have empty apply() method for this event or should framework just skip this event. (this can lead into hard discoverable typo errors)
    • Answer: I would prefer to hot have this methods in aggregate and have some kind of static analysis check for method name and type consistency (in PHP which does not support method overloading).
  • Is there any point of adding events when loading from history into the object "recorded events"?
    • Answer: No, if you load them there, they will be persisted once more and there will be a need for merge process.