All glossary terms
Design

Inversion of control

Inversion of control is the design principle that a component should not control the flow of its dependencies — instead, the framework or container controls flow and passes resources to the component when needed. Dependency injection is one form of IoC; event-driven callbacks and aspect-oriented programming are others.

The 'Hollywood Principle' (don't call us, we'll call you) is shorthand for IoC. In a non-IoC design, a component fetches what it needs and calls dependencies directly; in an IoC design, the component declares what it needs and lets the framework deliver it. The benefit is loose coupling and testability; the cost is a shallower stack trace and harder learning curve (the actual call path lives in framework config, not source code). Most modern application frameworks (Spring, Angular, NestJS, ASP.NET Core) build IoC in at the foundation; the question for a designer is rarely 'IoC or not' but 'how aggressively to lean on it'.

Related terms