Inversion of control

What is Inversion of Control (IoC)?

Inversion of Control is a design principle in which the control of creating, managing and providing objects is transferred from the application programmer to an external framework or container such as spring.
In other words, instead of we creating and managing objects, the framework takes responsibility of the same.

IoC helps us achieve the following:

1. Loose Coupling

2. Centralized Object Management

3. Lifecycle Management

4. Easier Testing

5. Flexibility

What is an IoC Container in Spring?

The IoC container is the core mechanism through which Spring implements IoC.

It is responsible for:

  • Creating objects (beans).
  • Managing their dependencies.
  • Injecting dependencies.
  • Managing bean lifecycle.
  • Maintaining bean scope.