In this chapter, we have examined DI with constructor injection. We have seen how easy it is to understand and apply. This is why it is the default choice for many programmers and in many situations.
We have seen how constructor injection brings a level of predictability to the relationship between an object and its dependencies, especially when we use guard clauses.
By applying constructor injection to our REST package, we were left with a collection of loosely coupled and easy-to-follow objects. Because of this, we were able to extend our test scenario coverage easily. We can also expect that any subsequent changes to the model layer are now unlikely to unduly affect our REST package.
In the next chapter, we will introduce DI with method injection, which (among other things) is a very convenient way to handle optional dependencies.