arrow_back
Back

Inversion of Control (IoC): containers, frameworks, and flow

Andrew Dorokhov Andrew Dorokhov schedule 1 min read

Inversion of Control (IoC) is a software design principle that refers to a pattern where the control flow of a program is inverted or “inverted” from the traditional procedural flow. In the traditional procedural flow, a program controls the flow of execution by directly calling and coordinating various functions or objects.

IoC typically involves a framework or container that manages the flow of control and dependencies in an application. Instead of a developer manually creating and managing object instances and their dependencies, the IoC container takes responsibility for creating and wiring objects together.

There are two common forms of IoC:

  • Dependency Injection (DI): This is the most common form of IoC, where the dependencies of a class or object are “injected” from an external source rather than being created within the class itself. The external source is typically an IoC container, which manages the creation and wiring of objects. DI can be achieved through constructor injection, setter injection, or interface injection.
  • Dependency Lookup: In this form of IoC, instead of objects being injected, a class or object looks up its dependencies from an external source or container when needed. The class explicitly asks for its dependencies from the container, usually through a lookup method or service locator.
code

Need Help with Development?

Happy to help — reach out via the contacts or go straight to my Upwork profile.

work View Upwork Profile arrow_forward
Next Article

Object-relational mapping (ORM): entities, mapping, and persistence

arrow_forward