Thanks to the author, you can get it with a special discount reserved to the readers of this blog!
TLDR: as much as possible
Suppose we dispatch an event when an order has been created and we only pass the order id.
Then a listener needs to retrieve the order by id.
The order data can change between order creation and order retrieval, even if that time is just some milliseconds.
That means that the order state retrieved by the listener is not guaranteed to represent the order state when the event was dispatched.
Thus, passing the entire order in the event has two benefits:
- we avoid the need of fetching data;
- we have the exact state of the object when the event was registered.
Posted with : ddd