Chapter 1. Dependency injection: what’s all the hype?

 

This chapter covers:

  • Seeing an object as a service
  • Learning about building and assembling services
  • Taking a tour of pre-existing solutions
  • Investigating the Hollywood Principle
  • Surveying available frameworks

“We all agree that your theory is crazy, but is it crazy enough?”

Niels Bohr

So you’re an expert on dependency injection (DI); you know it and use it every day. It’s like your morning commute—you sleepwalk through it, making all the right left turns (and the occasional wrong right turns before quickly correcting) until you’re comfortably sitting behind your desk at work. Or you’ve heard of DI and Inversion of Control (IoC) and read the occasional article, in which case this is your first commute to work on a new job and you’re waiting at the station, with a strong suspicion you are about to get on the wrong train and an even stronger suspicion you’re on the wrong platform.

Or you’re somewhere in between; you’re feeling your way through the idea, not yet fully convinced about DI, planning out that morning commute and looking for the best route to work, MapQuesting it. Or you have your own home-brew setup that works just fine, thank you very much. You’ve no need of a DI technology: You bike to work, get a lot of exercise on the way, and are carbon efficient.

Stop! Take a good, long breath. Dependency injection is the art of making work come home to you.

1.1. Every solution needs a problem

 
 

1.2. Pre-DI solutions

 
 
 

1.3. Embracing dependency injection

 
 

1.4. Dependency injection in the real world

 

1.5. Summary

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage