Jason Ragsdale – DPUG 4/13/2010
● DI is a technique for supplying an external dependency to a software
● DI involves at least three elements
● A dependent
● An injector (provider / container)
Highly coupled dependency
Benefits and Drawbacks
● Reduction of boiler-plate code
● Flexibility in changing out external dependencies
● Testing in general, ability to inject mock or dev dependencies
Types of DI
● Interface Injection
● in which the exported module provides an interface that its users must
implement in order to get the dependencies at runtime.
● Setter Injection
● in which the dependent module exposes a setter method that the
framework uses to inject the dependency.
● Constructor Injection
● in which the dependencies are provided through the class constructor.