Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DI vs IoC

 
Mourouganandame Arunachalam
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dhanji,

Could you please share your view on DI vs IoC? How these terminologies are related?

Thanks & regards,
 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Chrome Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Sandeep Awasthi
Ranch Hand
Posts: 597
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dhanji Prasanna
author
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I have answered the question here:
http://www.coderanch.com/forums/posts/list/460611#2055756
 
Mourouganandame Arunachalam
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vyas Sanzgiri wrote:


why ?
 
Mourouganandame Arunachalam
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Sandeep & Dhanji for your time.

 
Klaus Schultz
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)

Klaus
 
Dhanji Prasanna
author
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Klaus,

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!)

Dhanji.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic