liveBook · Manning

Inversion of control

Also called IoC

Inversion of control is a design principle in which control over execution flow, object creation, or dependency provision is transferred from application code to an external mechanism or component.

How 5 Manning books explain it

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.

How it is used
Explains how Spring takes over application execution to manage application code and coordinate components.
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.

Read how Spring Start Here, Second Edition explains inversion of control →

Functional Design and Architecture: Examples in Haskell

Inversion of control is a design technique in which client code depends on an interface or abstraction rather than directly controlling or selecting a concrete implementation.

How it is used
Decouples client code from concrete implementations while supporting modularity, readability, robustness, and testability.
How deep it goes
Explains contracts, replaceable implementations, modularity, a sensor example, and dependency injection for testing.
Examples
Uses a thermometer, sensor interface, receiver, observer, native readings, Celsius conversion, and mocked test dependencies.
What you can do after
Apply it via interfaces and injected dependencies to replace implementations and isolate code from external systems.

Read how Functional Design and Architecture: Examples in Haskell explains inversion of control →

Practices of the Python Pro

Inversion of control is a design technique in which control over object construction, behavior, or dependencies is transferred from a component to an external mechanism or caller.

How it is used
Makes existing applications flexible and extensible when adding features or replacing dependencies.
How deep it goes
Defines dependency passing, demonstrates replacement and testing, and stops short of broader implementation frameworks.
Examples
Uses Bicycle parts, CarbonFiberFrame, MockTire, and a GitHub stars importer preserving bookmark timestamps.
What you can do after
Apply dependency passing and optional behavior inputs to extend Python classes without editing their implementations.

Read how Practices of the Python Pro explains inversion of control →

Grokking Software Architecture

Inversion of control is a design principle in which control over object creation or execution flow is transferred from a component to an external mechanism.

How it is used
Separates checkout’s business workflow from low-level HTTP and provider concerns by injecting a service.
How deep it goes
Identifies hardcoded dependencies as an IoC violation and recommends service injection, but gives no implementation steps.
Examples
Uses checkout code with a hardcoded HTTP call and URL, noting the difficulty of adding another provider or logger.
What you can do after
Evaluate checkout code for hardcoded low-level dependencies and choose service injection as the remedy.

Read how Grokking Software Architecture explains inversion of control →

Kafka Streams in Action, Second Edition

Inversion of control is a design principle in which a framework or container controls object creation and dependency wiring instead of the application doing so directly.

How it is used
Uses Spring as an IoC container for wiring components in Kafka and Kafka Streams applications.
How deep it goes
Defines IoC, contrasts direct instantiation with interface injection, and identifies constructor, setter, and field injection.
Examples
Uses a payment processor, NetworkClient interface, SecureNetworkClient implementation, constructor injection, and mock instances.
What you can do after
Build flexible, testable Java components by injecting interface-based dependencies with Spring.

Read how Kafka Streams in Action, Second Edition explains inversion of control →

Also covered in

What to know first

Related concepts

Questions about inversion of control

What is inversion of control?

Inversion of control is a design principle in which control over execution flow, object creation, or dependency provision is transferred from application code to an external mechanism or component.

Which Manning books explain inversion of control?

Spring Start Here, Second Edition, Functional Design and Architecture: Examples in Haskell, Practices of the Python Pro, Grokking Software Architecture and Kafka Streams in Action, Second Edition.

What should I know before learning inversion of control?

Manning books that teach inversion of control usually introduce design pattern, HTTP, metadata and side effect first.

What is inversion of control a kind of?

Inversion of control is a kind of design pattern. A design pattern is a reusable, general solution structure for a recurring software design problem.

What is inversion of control also called?

Inversion of control is also called IoC.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.