# 
Dependence reversal principle

By [rojeck](https://paragraph.com/@rojeckluo) · 2021-11-18

---

    The definition of Dependency Inversion Principle (DIP): Programs must rely on abstract interfaces, not specific implementations. Simply put, it is required to program the abstraction, not the implementation, which reduces the coupling between the client and the implementation module.
    
    The meaning of relying on the principle of reversal
    The principle of dependency inversion requires us to refer to high-level abstraction classes as much as possible when passing parameters in program code or in association relationships, that is, use interfaces and abstract classes for variable type declaration, parameter type declaration, method return type declaration, and data type Conversion, etc., instead of using specific classes to do these things. In order to ensure the application of this principle, a concrete class should only implement the methods declared in the interface or abstract class, and should not provide redundant methods, otherwise it will not be able to call the new methods added in the subclass. After the introduction of the abstraction layer, the system will have good flexibility. Try to use the abstraction layer for programming in the program, and write the specific classes in the configuration file. In this way, if the system behavior changes, only the abstraction layer is required. Expand and modify the configuration file without modifying the source code of the original system, and expand the functions of the system without modification to meet the requirements of the opening and closing principles.

---

*Originally published on [rojeck](https://paragraph.com/@rojeckluo/dependence-reversal-principle)*
