We have seen how decorators allow us to abstract away certain logic into a separate component. The main advantage of this is that we can then apply the decorator multiple times into different objects in order to reuse code. This follows the Don't Repeat Yourself (DRY) principle since we define certain knowledge once and only once.
The retry mechanism implemented in the previous sections is a good example of a decorator that can be applied multiple times to reuse code. Instead of making each particular function include its retry logic, we create a decorator and apply it several times. This makes sense once we have made sure that the decorator can work with methods and functions equally.
The class decorator that defined how events are to be represented also complies with the DRY principle in the sense that it defines one specific place for...