1976 shaares
6 private links
6 private links
2 results
tagged
dependency
The idea behind dependency injection really is quite simple. You have a bunch of objects (I'll refer to them as "services"), some of which depend on the others. Each service explicitly declares its dependencies in some way (for example, by listing them as parameters to its constructor). An external piece of code (the so-called injector) creates and provides the dependencies accordingly, based on these declarations. This is a nice improvement over having everything be a singleton or passing around a huge service locator.