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

Inversion of control

 
Greenhorn
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.
 
Rancher
Posts: 989
9
  • 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.
 
ranger
Posts: 17344
11
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.

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