This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
In short, IOC is generic term which includes dependency injection and dependency lookup, while dependency injection is concrete form of IOC. In most of the places they are used interchangeably. But fact is IOC is generic and DI is concrete.
To add a historical point: Inversion of Control is a general term first used to explain how OO frameworks work. Inversion of Control is often pronounced as the Hollywood principle "don't call us, we will call you". Take for example the design pattern "Template method": your code is called from the framework. This design pattern shows also the big difference in this meaning of IoC versus DI: the Template Method calls your code at a specific point in a sequence of actions done by the framework. DI as I know it is completely static, constructing a net of objects at initialization time and injecting this environment into the components which need it.
DI is clearly a form of IoC but a very special one.
Dhanji, do you agree this? (besides my crude characterization of DI)
Joined: Aug 30, 2009
There are many nuanced interpretations of the differences between them. As I said in my linked post above, I try to avoid IoC altogether as it tends to apply too broadly, and stick instead to DI which everyone is rather clear on (or hopefully can be convinced so!)