1.

What is IOC (Inversion of Control)?

Answer»

Inversion of control is a software engineering principle that transfers control of objects or parts of a program to a container or framework. In object-oriented programming, it is most often USED. In contrast to TRADITIONAL programming, where our custom code calls to a library, IoC allows a framework to control a program's flow and make calls to our custom code. Frameworks use abstractions with other built-in BEHAVIOURS to enable this. If we WANT to add our own behaviour, we must extend the framework classes or add our own classes.

The benefits of this architecture are:

  • Decoupling the implementation of the task
  • It makes switching between different implementations easier
  • Increased program modularity
  • It is easier to test a program by isolating a component or mocking its dependencies and enabling components to communicate via contracts

Various mechanisms such as Strategy design, service locator pattern, factory pattern and dependency injection (DI) can be used to implement IOC.



Discussion

No Comment Found