3

The word "Dependency" is used a lot in programming. But I think we might be using it wrong in many ways. I will use "Dependency Injection" in this post as an example. According to the Dictionary.com, the "Dependency" means:

  1. the state of being dependent; dependence.
  2. something dependent or subordinate; appurtenance.
  3. an outbuilding or annex.
  4. a subject territory that is not an integral part of the ruling country.

Let's take the second meaning. Dependency denotes a thing that depends on another thing(s). However, when we say "Dependency Injection", what the dependencies are not the objects requesting other objects to be injected to themselves, but the objects that are being injected. But according to the meaning given in the dictionary, this understanding is wrong. Actually, we are not injecting dependencies, but dependencies request other objects to be injected since they depend on those objects that they specify in their constructors. Perhaps a name like "Requestor Dependency" pattern would be accurate.

A justification would be that we call the injected objects "Dependencies" because they are part of a dependency graph in which they depend on the other objects, but from the more realistic stand point, this justification of the way how the word "dependency" is used in DI pattern seems not sufficient to me.

I am not a native English speaker. Therefore, I may be wrong on this subject. But whenever I think about dependency, the meaning of it in the dictionary and how it is used in the programming conflict with each other.

6
  • 1
    I would like to get a comment from the person who downvoted my post as to what he/she saw wrong in my post.
    – Tarik
    Commented Aug 15, 2016 at 3:14
  • 2
    Words can have different meanings in different contexts. Sometimes even contradictory meanings (take the word 'literally' for instance: it is often used to mean the opposite of the standard dictionary definition). That doesn't mean they are wrong. I wasn't your downvoter, though. :-)
    – Eric King
    Commented Aug 15, 2016 at 3:43
  • 1
    Related: what-is-the-correct-word-for-dependee Commented Aug 15, 2016 at 5:22
  • 1
    Use this definition for the context of software development. Commented Aug 15, 2016 at 5:25
  • I'm not english speaker, but looking at dictionary examples, I don't see any problem. "the country's dependency on foreign oil" is to "Module A's dependency on Module B" as "foreign oil is dependency" is to "Module B is dependency". But that might be my software lingo influencing me.
    – Euphoric
    Commented Aug 15, 2016 at 6:00

1 Answer 1

7

Dependency Injection uses the term "dependency" correctly.

A dependency is simply a setting, value, or configuration on which a program depends. Looking up dependent is much more instructive. There one finds (slightly paraphrasing and abridging, and amongst other meanings):

  1. relying on someone or something else
  2. conditioned or determined by something else; contingent
  3. subordinate; subject
  4. not used in isolation; used only in connection with other forms
  5. having values determined by one or more independent variables

Those all fit "dependency injection" quite nicely.

In DI, the values and configurations a program depends on are externally provided ("injected"). In practice, the application server, program loader, test harness, or other "middleware" responsible for injection provides not just simple values (e.g. "the file to process is xyz.jpg" or "the program should use 6 worker threads for this run"), but also the names or addresses of services (e.g. databases, parsers, libraries) the program should use, and the credentials and configurations with which to use those services. Whether simple values or definitions of complex services and objects, the information injected invariably specifies things on which the target program depends, and that the developer has judged appropriate to be externally defined rather than hard-wired into program source code.

It is true that the "dependency" of DI does not comport with every possible meaning of "dependency." Its "annex" and "subordinate territory" meanings, for example, are absent. But that's par for the course in using natural languages in technical settings. Nor does a phrase like "operating system" align with every possible meaning or sense (denotation or connotation) of "operating."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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