Inversion of Control(IoC) - short and to the point

Inversion of Control(IoC) - short and to the point

In the previous article, I mentioned Inversion of Control in context of Spring Framework basic elements.

In this article, we will understand what exactly IoC is, in practical way.

Simple definition

Inversion of control is a programming principle or a set of rules. Using this rule, inverts the flow of control as compared to traditional flow like in procedural programming.

IoC principle provides flow of control exactly in opposition to standard flow of control used in procedural programming.


Table below, shows two different flows of control.


Procedural programming

In the procedural programming, flow of control looks like in the left column. Code written by You, uses libraries to execute coded functions.

General, your code has control over the program. It just uses functions/classes/interfaces which are provided by different libraries.

Inversion of Control

However, with Inversion of Control principle preserved - the framework takes control over the application and handle stuff like:

  • starting an app
  • loading configuration
  • providing ready-to-use components.

"Your code" is only being used by framework to provide specific operations like:

  • process data
  • handle data models from database, etc.


"The best explanation is the shortest one" and this rule I had in my mind while writing this post.

To be honest, I have spent a lot of time reading and watching lots of materials about Inversion of Control, but what you have read in my article is everything that you have to know about this principle. I hope it is helpful!