• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Inversion of control

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have seen references to this term but I can't seem to understand what it actually means. Can someone in very simple terms explain what this is? Also, is the term "dependency injection" the same thing? What exactly do they mean by dependency injection? What is the use of performing such an operation?

I guess I'm reading all these things about the Spring framework but can't really figure out why it is so useful and what it really accomplishes over the traditional approach. Thanks much
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both IoC and DI mean the same. DI means that depenedencies are injected into the code by the container (Spring , Pico, Hivemind) without you having to do that. For example your code may be having dependecy on Datasource. You will need to write the lookup code using JNDI. Let us say that you need to port you code to non -JNDI environment then you will have to replace the JNDI lookup code. If you specify this in a XML as Spring does you can change the XML file to reflect the new environment without having to change code. Advantages are it becomes easier to test different implementation just by changing the XML file, code does not manage the dependencies and reduced coupling between components. I am quite new to DI and never worked on Spring or any DI containers. I feel that there is too much hype surrounding DI.

Here is good article
http://www.theserverside.com/articles/article.tss?l=IOCBeginners
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic