• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

DI vs IoC

 
Ranch Hand
Posts: 398
Android Eclipse IDE Ubuntu
  • 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,
 
Ranch Hand
Posts: 686
Netbeans IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
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.
 
author
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I have answered the question here:
https://coderanch.com/forums/posts/list/460611#2055756
 
Mourouganandame Arunachalam
Ranch Hand
Posts: 398
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vyas Sanzgiri wrote:



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

 
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
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
Boost this thread!