Dealing the past with events
When we implement code handling the command message, we may contextually make some mistakes, such as:
Executing some other operation on another entity, for example, because it needs to change consistently with the first operation
Tracing the fact that the operation has been executed in a log file
Forget testing how command execution is performing in terms of speed and resource usage. Each of these mistakes has some effect on how we handle the entire project.
The first mistake is a matter of responsibility. For example, when we add an item to the basket we need to change the product availability into the store (that is, another entity). Is it correct that the same code that updates the basket updates the store? No: basket and store are two entities (or better, aggregates in DDD terms) that have two different lifetimes and responsibilities, so they need to be well separated into different places. The store should be informed that a basket has changed and it must change...