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:

2.1. Bootstrapping the injector

2.2. Constructing objects with dependency injection

2.3. Metadata and injector configuration

2.4. Identifying dependencies for injection

2.5. Separating infrastructure and application logic

2.6. Summary