DEV Community

Said Olano
Said Olano

Posted on

Inversion of Control Principle

Inversion of Control is also known as the Hollywood Principle, "Don't call us, we'll call you". It is a design principle in which custom-written portions of a computer program receive the flow of control from a generic framework.

Inversion of control carries the strong connotation that the reusable code and the problem-specific code are developed independently even though they operate together in an application.

Inversion of control is used to increase modularity of the program and make it extensible.

  • To decouple the execution of a task from implementation.
  • To focus a module on the task it is designed for.
  • To free modules from assumptions about how other systems do what they do and instead rely on contracts.
  • To prevent side effects when replacing a module.

Where we can see its usage:

  1. Using Factory pattern
  2. Using Service Locator pattern
  3. Using Dependency Injection
  4. Using contextualized lookup
  5. Using Template Method pattern
  6. Using Strategy pattern

Top comments (0)