Inversion of control
Inversion of control is a design principle that delegates application flow, object creation, or dependency selection from application components to an external mechanism or caller.
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 →
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 →
Related concepts
- dependency injectionequivalent to · Dependency injection is a software design technique in which a component receives its dependencies from outside rather than creating or locating them internally.
- dependencyuses · A software dependency is a component, resource, or prerequisite on which another software component or operation relies to function or proceed.
- contractuses · An API contract is a specification of the operations, data, and behavioral expectations that govern interactions between software components.
- flexibilityproduces · Flexibility is the capacity of a system, design, or process to adapt to changing requirements or conditions without extensive restructuring.
- design patternkind of · A design pattern is a reusable, general solution structure for a recurring software design problem in a particular context.
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.


