domain-driven-designdomain-modelevent-storming

Event Storming : Domain Event "Add to Cart Requested" is Good or Bad practice?


I have a question about "Domain Events"(orange post-it) in Event Storming

When I look some examples of Event Storming, I sometimes see Domain Events that look like this:

However I'm wondering if it's a good practice to create orange post-it like this, because it creates a kind of repetition. For example :

And I feel like it's a bad practice because that multiplies the number of post-it by 2 in my opinion.

If you think it's interesting to have orange post-its like this, can you explain why? If you think it is not,can you explain too ?

Thank you for your future anwsers.


Solution

  • As with everything in domain driven design, it depends on the domain.

    As a general rule, domain events are those which change the state of the system in some way, which generally means that there needs to be at least one command or query somewhere in the system which has a different result/effect in the universe where that event is recorded (i.e. stored, broadcast, whatever) from in the universe where that event is forgotten/ignored. If there's no command or query that's affected by this event, it's almost certainly not a domain event.

    So for AddToCartRequested, if nothing changes unless and until there's an AddedToCart event, then AddToCartRequested isn't a domain event. But if there's a process with its own state for adding an item to the cart (e.g. it's a saga), then the AddToCartRequested event changes some state (it might for instance reserve inventory of the item if the business is willing to lose a sale in order to avoid having to perform a compensatory transaction) and is a bona fide domain event (it's probably a good idea to also have an AddToCartRejected domain event which returns things to the approximate status quo).

    Note that there's an interesting question about whether observability (e.g. grafana or whatever) constitutes a read model for your domain: from this perspective, having a graph of attempts to add items to carts would be a query which is affected by the presence or absence of the event. (This perspective leads to an argument that nearly all logging and/or application-level metrics are just really crude domain events...).