File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes Inversion of control Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Inversion of control" Watch "Inversion of control" New topic

Inversion of control

prasad chowdary

Joined: Feb 18, 2012
Posts: 18
hello experts,

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

thanks in advance.
E Armitage

Joined: Mar 17, 2012
Posts: 989
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.
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

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.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Inversion of control
It's not a secret anymore!