After examining one of the most unique forms of dependency injection (DI), monkey patching, in this chapter, we take it to the other extreme and look at perhaps the most normal or traditional, constructor injection.
While constructor injection is so ubiquitous that you may even have used it without realizing it, it has many subtleties, particularly concerning advantages and disadvantages, that bear examination.
Similar to the previous chapter, we will apply this technique to our sample service, where we will reap significant improvements.
The following topics will be covered in this chapter:
- Constructor injection
- Advantages of constructor injection
- Applying constructor injection
- Disadvantages of constructor injection