• 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Inversion of control

Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello experts,

In springs the terms Inversion of Control (ioc) and Dependency Injection are same.

thanks in advance.
Posts: 989
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not really, but dependency injection is used to achieve inversion of control.
One could implement inversion of control using a service locator or the factory pattern rather than dependency injection.
Posts: 17344
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can think of the terms as one being a concept and the other an action to put that concept into action.

So Inversion of Control is a concept. Basically saying that one class isn't responsible for creating and getting another class it needs a reference too.

Dependency Injection is the action of another class injecting a dependency into the class that needs it. That is why the poster before me says that there are other actions/patterns that can also be used to implement the concept of Inversion of Control.

Example. SuperMan did not create his own super powers. They were given to him by outside forces. That is Inversion of Control.

If the action was he landed on earth and earth gave him his super powers you could say that is Dependency Injection. But if Superman got his powers by going to a special store/factory and asking for specific powers that the factory creates and injects into him, that is another implementation of Inversion of Control.

The only hero that actually created their own super powers, no one else can do this, is Chuck Norris.

Every snowflake is perfect and unique. And every snowflake contains a very tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!