# inversion of control

> software programming technique in which general framework code calls into business-logic subroutines

**Wikidata**: [Q666438](https://www.wikidata.org/wiki/Q666438)  
**Wikipedia**: [English](https://en.wikipedia.org/wiki/Inversion_of_control)  
**Source**: https://4ort.xyz/entity/inversion-of-control

## Summary
Inversion of control (IoC) is a software-architecture principle that flips the normal flow of program control: instead of application code calling into a reusable library, a generic framework calls application-specific “business logic” subroutines supplied by the developer. By letting the framework decide when and how to invoke user code, IoC decouples components and makes systems easier to extend, test, and maintain.

## Key Facts
- Classified as an architectural pattern, a software-design pattern, and a field of study (Wikidata instance_of statements).
- Listed as a subclass of software architecture and is partially coincident with event-driven architecture.
- Uses subroutine calls as its basic mechanism (Wikidata property “uses”).
- Recognized under the aliases IOC and Inversión de control.
- Has 19 Wikipedia sitelinks across 11 languages (ar, de, en, es, fa, fr, he, hu, it, ja).
- Stack Overflow tag: https://stackoverflow.com/tags/inversion-of-control.
- Freebase ID /m/05dtgl (sourced 2013-10-28).
- Microsoft Academic IDs (discontinued): 10676104 and 37897654.
- Quora topic: Inversion-of-Control; Zhihu topic ID 19628542.
- OmegaWiki defined meaning ID 1265479.

## FAQs
### Q: How is inversion of control different from dependency injection?
A: Dependency injection is one concrete technique that applies IoC: the framework “injects” dependencies into objects instead of objects creating them. IoC is the broader principle; dependency injection is one way to achieve it.

### Q: Does IoC require an object-oriented language?
A: No. While many OO frameworks use IoC, the core idea—relinquishing control of program flow to a reusable framework—can be implemented in any paradigm that supports subroutine calls.

### Q: What common frameworks use inversion of control?
A: Most modern application frameworks rely on IoC: web frameworks (Spring, ASP.NET Core), test runners (JUnit, pytest), and UI toolkits (Angular, React hooks) all invoke user-supplied callbacks or lifecycle methods.

## Why It Matters
Before IoC, developers wrote “glue code” that explicitly called library routines; changes in the library often rippled through application code. IoC reverses these dependencies so the framework—already tested and optimized—handles the sequencing, threading, and lifecycle events while the developer supplies only the business-specific logic. This separation yields looser coupling, better testability (easy to inject mocks), and cleaner domain code. Entire ecosystems (Spring, Jakarta EE, .NET) now revolve around IoC containers that wire components automatically, making large-scale applications feasible and evolvable. Without IoC, modern plug-in architectures, microservice frameworks, and even operating-system kernels would be far more monolithic and brittle.

## Notable For
- First principle to formalize “don’t call us, we’ll call you” in software design.
- Enables dependency-injection containers that power millions of enterprise Java and .NET applications.
- Underpins the template-method pattern and event-driven architectures.
- One of the few patterns explicitly listed as both an architectural and a design pattern in Wikidata.
- Present in 11 language editions of Wikipedia, indicating global pedagogical reach.

## Body
### Architectural Position
IoC sits under software architecture in the taxonomy of patterns and is closely related to dependency injection and the template-method pattern. It is also described as a facet of control flow.

### Mechanism
The framework defines extension points—callbacks, lifecycle methods, or interfaces—and the developer implements these subroutines. The framework’s main loop then decides when to invoke them, passing any required context.

### Related Patterns
- Template Method: defines skeleton algorithm, letting subclasses override specific steps; relies on IoC for the base class to call subclass methods.
- Dependency Injection: achieves IoC by handing objects their dependencies rather than having objects fetch them.
- Event-Driven Architecture: overlaps IoC because event loops dispatch to user handlers.

### Adoption
Every major enterprise framework since the early 2000s embeds IoC: Spring (Java), Guice (Java), ASP.NET Core (C#), Laravel (PHP), and Angular (TypeScript). Operating systems and game engines likewise use IoC for driver hooks, plug-ins, and scripting APIs.

## References

1. Freebase Data Dumps. 2013
2. Quora