Hooks
While the Façade has to be explicitly implemented to allow different code paths at runtime, there might also be scenarios where we are required to make changes to the code that we don't own. In these scenarios, we can implement a hook, which is nothing more than a function call that executes business logic outside of the code, but inside the transaction. The alternative to implementing hooks is raw source code modification, including creating additional variables.
The advantages of implementing hooks can be found in the area of upgradability. It does not increase maintainability, mainly because the name of the hook does not indicate what the hook does, but where it is called from. Hence we can see in the original source that there is a hook, but we need to use a Go To
definition in order to see what business logic is executed.
Let's look at hooks with the help of an example:
Remember, we only implement hooks when we don't want to disturb the original source...