1

In many articles i read about Dependency Injection Container, and many others talk about IoC Container. And while there must be some places that mention both, i have not come across one yet. So the question is: What is the relationship between these two? Are they the same thing? or is one an implementation of another? Or ... ?

Konstantin
  • 3,294
  • 21
  • 23

1 Answers1

1

I would say they are two different phrases that refer to the same thing, and I will go out on a limb and suggest that "IOC Container" is probably the more idiomatic / widely used of the two.

I more often hear the phrase "Dependency Injection Framework"* as opposed to "container" and I imagine that's what most people actually mean when they say "Dependency Injection Container" - bearing in mind that all DI Frameworks will have a "container" which is the object that holds type mappings and is the entry point for the work of resolving object graphs for injection at runtime.

So for example, in the Ninject Dependency Injection Framework, the StandardKernel is the "container".

I hope that hasn't confused you more :)

Update

*As Steven has pointed out, the term "Framework" here could indeed be inaccurate and the term "library" is possibly more correct. In any case, you can't go wrong calling them "IOC Containers".

Community
  • 1
  • 1
Stephen Byrne
  • 7,400
  • 1
  • 31
  • 51
  • But in fact, the use of the word "framework" is incorrect. IOC containers are libraries; they are just tools that we call, instead of frameworks like ASP.NET, WCF and WPF that run before our code runs. – Steven May 03 '15 at 15:08
  • 1
    @Steven - fair point although I don't fully agree I don't want to get into an argument about semantics so I have updated the answer accordingly. – Stephen Byrne May 03 '15 at 16:08
  • @Konstantin : "Idiomatic" - "Peculiar to or characteristic of the style or manner of a particular group or people" [Source](http://www.thefreedictionary.com/idiomatic). In this case the particular group of people are programmers. If you feel there is a better word, let me know, I'll be happy to update the answer (or you can make a proposed edit). – Stephen Byrne May 04 '15 at 17:50
  • @Stephen As a non-native (neither English nor this particular group of elite programmers that use IoC containers and words like "idomatic" in one sentence) speaker i would be satisfied with just 'more correct/appropriate' or 'more widely used'. But at my next job interview I will use 'idiomatic'. :) Thanks – Konstantin May 04 '15 at 18:44