Event modeling : specificity

Hi all,

I have a question on event modeling. As a simple example, let’s say we have a Customer domain and we have a range of events that deal with the state of a Customer. In this case a Customer has a very large number of attributes (e.g. initials, firstName, lastName, emailAddress etc.). How specific should one make events in this case ? For example, on one extreme one could choose to use one very general CustomerUpdatedEvent, where one or more attributes might have changed. On the other extreme one could choose to have specific events for each attribute (CustomerFirstNameUpdatedEvent, CustomerLastNameUpdatedEvent etc).

I am wondering if there is sort of a ‘best practice’ for this ? Or which pro’s/cons that maybe some of you have experienced after having made choices around this matter ?

I have had great success with very specific events.

You will most likely run into quite a lot of annoyances if you have big generic events, as the event handlers will have more complexity to them and any change to the protocol will have a bigger impact.

I like to make sure that my commands / events mean something obvious and synonymous so that it is very clear what you want to do and what has actually happened. Your events should reflect what change has happened to the domain, and whilst the customer technically has changed, it’s not as close of a representation of the truth as a more specific event.

If you take your example it would be something like
ChangeFirstName as the command and FirstNameChanged as the event.

3 Likes