Logging
Application logging is one of the most fundamental aids when it comes to diagnosing issues in running code. In a lot of code bases, logging tends to be an after-thought where developers add log statements only after they encounter problems. This results in log statements being strewn almost randomly throughout the code base. Here is a simple example of code within a command handler to log its execution time among other things:
There is no doubt that this logging code can be invaluable when troubleshooting issues. However, when we look at the preceding code, the logging code seems to dominate the entire method obscuring the domain logic. This might feel innocuous, but when this is done in multiple places, it can get quite repetitive, cumbersome, and error-prone – compromising readability. In fact, we have seen cases where seemingly innocent log statements have introduced performance issues (for example, within a loop with an expensive argument...