C# object-oriented design principles (3) rely on inversion principle

Rely on the definition of the inversion principle:

1. High-level modules should not rely on low-level modules, both of which should rely on their abstraction
2. Core idea: Interface-oriented programming, not implementation-oriented programming
3. Previously implementation-oriented, now abstraction-oriented

The effect of relying on the principle of inversion:

1. One of the important ways to realize the opening and closing principle, reducing the coupling between the customer and the implementation module
2. Improve the stability of the system
3. Reduce the risk of parallel development
4. Improve the readability and maintainability of the code

Rely on the realization of the inversion principle:

1. Each class should provide an interface or abstract class as much as possible
. 2. The variable declaration type should be an interface or an abstract class as much as possible.
3. No class should be derived from a concrete class
. 4. When using inheritance, try to follow the Richter conversion principle.

Guess you like

Origin blog.csdn.net/MrLsss/article/details/109248481