Dependency injection

Essentially means this: class dependencies are "injected" into the class via the constructor or, in some cases, "setter" methods.

One of the primary benefits of it is the ability to swap implementations of the injected class. This is useful during testing since you can inject a mock or stub and assert that various methods were called on the stub.

Dependency injection — Structure map

Clickable & Draggable!

Dependency injection — Related pages: