Home computickets What is the Inversion of Control (Inversion Of Control, Ioc) differs from...

What is the Inversion of Control (Inversion Of Control, Ioc) differs from dependency inversion (Dependency Inversion Principle, Dip)?

Author

Date

Category

In the literature there are two different concepts Control inversion and The principle of inversion of dependencies , which are formulated equally:

  • Upper level modules should not depend on the low level modules. Both types of modules should depend on abstractions.

  • abstraction should not depend on the details. Details should depend on abstractions.

What is the difference?


Answer 1, Authority 100%

Inversion of Control is a common term that characterizes the software architecture. Usually applied to frameworks – control inversion is one of the characteristics.

frameworks provide connection points in which you can write your code. But at the same time, the general execution of the program is still running the framework, calling your code from time to time. Inversion is that, in contrast to the traditional approach, you do not call the library code, and the library code causes you. Examples may be ASP.NET and WPF with their events.

At the same time, the principle of control inversion can be used in a smaller scale. For example, there is a layer of logic (BL) and data access (DAL). It is well known that DAL cannot contact BLL. But sometimes there is a need for the DAL level to perform a certain code that should belong to BLL. In this case, the DAL will start some interface, this interface is implemented at the BLL level, and the instance of a particular implementation is transmitted from BLL to DAL. This example, in particular, is consistent with DIP.

Dependency Inversion Principle gives recommendations on what should be dependent. This is exactly what you quoted:

  • Upper level modules should not depend on the low level modules.
    Both types of modules must depend on abstractions.
  • abstraction should not depend on the details. Details should depend on
    abstractions.

You could also hear about dependency injection . Dependency Implementation is a link between IOC and Dip . It is One of the ways Implementation of control inversion.


Better read English wiki about ioc and DIP , there is much better everything is explained. I think even with the help of Google Translete it will be more useful than articles in Russian wiki.

As a Russian-speaking source, I can recommend the article di vs . Dip VS. Ioc from Sergey Teplikova. Perhaps he will even go to this question and explain everything as it should:).

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions