jargon

Comparison

Dependency injection containervsPure dependency injection

Dependency injection container

you registered an interface against a class once, and everything that needs it gets one without anybody passing it.

A library that holds the map from abstraction to implementation and constructs object graphs on demand, handling lifetimes and nested dependencies. It earns its place in an application with hundreds of components; below that it mostly replaces a readable composition root with a configuration you cannot step through. Its two recurring costs are resolution errors that surface at runtime rather than compile time, and lifetime mistakes the container will happily make for you.

Full entry →

Pure dependency injection

the wiring is forty lines of ordinary constructor calls at startup, and you can step through every one of them.

Assembling the object graph by hand in the composition root instead of using a container. It is compile-time checked, greppable and debuggable, which are exactly the properties a container gives up. The dismissive nickname has outlived its accuracy: for a service with a few dozen components, hand-wiring is usually less total work than configuring a container to do it.

Full entry →

Related comparisons