Lilly
04/10/2023, 5:51 PM...all handlers define their own interface (there is no common interface). This makes it hard to extend the command handlers with new features and Cross-Cutting Concerns. For example, I would like to measure the time it takes to execute every command and log this information to the database. How can we do this?
...
All these problems can be solved elegantly by having all command handlers implement a single generic interfaceHow does the common interface solve the problem to implement time measuring?
dewildte
04/10/2023, 7:37 PMdewildte
04/10/2023, 7:37 PMWhat does adding an interface give us? Well frankly, a lot! As nothing depends directly on any implementation but instead depends on an interface, you can now replace the original command handler with any class that implements the new interface. Ignoring—for now—the usual argument of testability, look at this generic class:
dewildte
04/10/2023, 7:37 PMdewildte
04/10/2023, 7:39 PM