DDD journey: how much information should an event contain?

Posted on May 6, 2021

Foreword

In the series of my short DDD journey articles, I’ll summarize some of the insights that came out speaking with the author of the Advanced Web Application Architecture book.

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.

Enjoy!


Posted with : ddd