Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

In tutorials and books, I have never seen a single word describing the object that the injected object is injected into. Instead, other terms are used, like "injection point" which don't denote the object containing the injected object. And nothing I can think of sounds right, except maybe "injection target" - but I have never read it anywhere.

Is there a single word or a simple expression for it, or is it like the "He-Who-Must-Not-Be-Named" from a recent fantasy book series?

share|improve this question

closed as primarily opinion-based by gnat, MichaelT, Kilian Foth, jwenting, Bart van Ingen Schenau Sep 22 at 10:48

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

3 Answers 3

up vote 5 down vote accepted

Wikipedia calls it the "Dependent Consumer," or simply the "Dependent Object."

...Dependency injection involves at least three elements:

  • a dependent consumer,
  • a declaration of a component's dependencies, defined as interface contracts,
  • an injector (sometimes referred to as a provider or container) that creates instances of classes that implement a given dependency interface on request.

The dependent object describes what software component it depends on to do its work. The injector decides what concrete classes satisfy the requirements of the dependent object, and provides them to the dependent.

In conventional software development, the dependent object decides for itself what concrete classes it will use. In the dependency injection pattern, this decision is delegated to the "injector" which can choose to substitute different concrete class implementations of a dependency contract interface at run-time rather than at compile time.

Being able to make this decision at run-time rather than compile time is the key advantage of dependency injection. Multiple, different implementations of a single software component can be created at run-time and passed (injected) into the same test code. The test code can then test each different software component without being aware that what has been injected is implemented differently...

share|improve this answer

Container sounds like a perfectly acceptable term to me. EG IThing is injected in to its container

Edit -- Comments rightly say that container is already in use in this situation. How about dependee eg The dependency is injected in to its dependee?

share|improve this answer
2  
That would be a good name, but unfortunately, 'container' is already taken - by the facility that is responsible for managing the objects and injecting them into each other. –  kostja Oct 10 '12 at 19:19
1  
Bugger. That would explain why that term jumped to mind immediately and seemed to fitting then! –  AndyBursh Oct 10 '12 at 19:22

There is no formal name - I usually think about it as the object that needs the dependency.

Call it the dependant object...

share|improve this answer
    
It's supposed to be one word. How about DependentObject? :-) –  Karl Bielefeldt Oct 10 '12 at 19:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.