File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Inversion of control" Watch "Inversion of control" New topic
Author

Inversion of control

prasad chowdary
Greenhorn

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
Rancher

Joined: Mar 17, 2012
Posts: 892
    
    9
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
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

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.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inversion of control