liveBook · Manning

Inversion of control

As explained in Spring Start Here, Second Edition

Inversion of control is a design principle in which a framework or container takes responsibility for coordinating application components instead of the components controlling that coordination themselves.

Inversion of control (IoC) means letting a framework such as Spring manage application execution instead of having the application coordinate everything itself. Configuration tells Spring how to manage application code; Spring can create objects and call or intercept their methods. section 1.2

Figure 1.4 Inversion of control. Instead of executing its own code, which makes use of several other dependencies, in an IoC scenario, the app execution is controlled by the dependency. The Spring framework controls an app during its execution. Therefore, Spring implements an IoC scenario of execution.

The diagram contrasts application-controlled execution with Spring taking control during execution. section 1.2

Spring manages an object

An object added to Spring’s IoC container, also called the Spring context, becomes available for Spring to manage. For example, Spring can intercept one of its methods to log errors during execution. section 1.2

How Spring Start Here, Second Edition covers it

How deep it goes
Defines IoC and describes configuration, object creation, and method interception without detailing their implementation.
Examples
Illustrates control with a Spring execution diagram and error logging through method interception.
What you can do after
Understand how Spring uses configuration and its container to manage application objects and methods.
How it connects
Connects IoC with the Spring framework, the IoC container, the Spring context, and Spring AOP.

Also explained in

Compare how 5 books explain inversion of control →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring Start Here, Second Edition. The section links point to the parts of the book it draws on.