Chapter 2. Time for injection
This chapter covers:
- Using dependency injection
- Identifying dependencies by keys
- Comparing string, type, and combinatorial keys
- Separating infrastructure from application logic
“We shape our buildings, thereafter they shape us.”
Winston Churchill
In chapter 1, we saw that dependency injection offers a unique and concise solution to the problem of constructing object graphs, with a strong emphasis on unit testing. The crux of this solution is the fact that all your code is freed from constructing dependencies. Code written with DI in mind is behaviorally focused and without distracting clutter. Why is this important?
While the answer may seem self-evident (hard to argue with the less and more precise), it is well worth spelling out: