Dependency-inversion principle
A. High-level modules should not depend on low-level modules. Both of them should depend on abstraction.
B. abstraction should not depend on details, but on abstraction.
The high-level module containsProgramImportant policy selection and business model in. it is these high-level modules that make all their applications different from others. if the upper layer depends on the lower layer, the changes to the lower layer modules will directly affect the upper layer modules, forcing them to make changes in turn.
Similar to OCP principles.
Each high-level layer declares an abstract interface for the required service. at a lower level, these abstract interfaces are implemented. Each high-level class uses the next layer of services through this abstract interface, the lower layer must implement high-level interfaces. Therefore, the lower layer is dependent on the higher layer.
Dependency inversion and interface ownership inversion.
Dependent on abstraction.
Heuristic rules:
1. No variable should hold a pointer or reference pointing to a specific class.
2. No class should be derived from a specific class (beginning with abstraction and coming from a specific class)
3. No method should overwrite the implemented methods in any of its base classes.