Monkey patching as a form of DI is very different from the other methods presented in this book in both implementation and effect. As such, there are some situations in which monkey patching is either the only option or the only succinct one. Monkey patching's other advantages are detailed in this section.
DI via monkey patching is cheap to implement—In this book, we have talked a lot about decoupling, which is the idea that separate pieces of our code should be kept separate, even though they use/depend on each other. We introduce abstractions and inject them into each other. Let's step back for a moment and consider why we want the code decoupled in the first place. It's not only about making it easier to test. It's also about allowing the code to evolve separately and provide us with small groups, mental boxes if...