alphagov/specialist-publisher — pull request #7 by heathd (2014-02-18 11:08:56+00:00)
Title: Dependency injection

Uncle Bob said "Depend on abstractions, not concretions". This is the D
in the SOLID principles of OO design[1]

A dependency injection container makes life a little easier when
following the dependency injection pattern. It holds dependency
configuration ("wiring"), and implements conventions for
fulfilling object dependencies, as follows:

1. constructor injection

the container will use the names of constructor arguments and find
dependencies with the corresponding name

2. struct member injection

since we commonly use Structs as value objects, the container also
supports struct members as dependency definitions

Different containers can be used in different contexts (for example in
production vs. test).

[1] http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)