Object-Oriented design principles:
1. Single Duty principle (SRP): each class in the system should have only one responsibility.
Benefits: cohesion, low coupling.
2. Opening and closing principle (OCP): open for extension, closed for modification.
Benefits: Increased adaptability and flexibility, stability and continuity, reusability and maintainability.
3. The Richter Replacement principle (LSP): Wherever the parent class appears, it can be replaced with its subclasses without compromising performance.
Polymorphism is the implementation of the Richter scale substitution principle.
4. Dependency inversion principle (DIP): high-level modules should not rely on the underlying modules, both should rely on their abstraction; abstractions should not depend on detail, and detail should be dependent on abstraction.
Benefits: Improve the stability of the program, maintainability, Extensibility.
5. Interface Isolation principle (ISP): using multiple specialized interfaces is better than using a single total interface.
Benefit: Do not force new functionality to implement unnecessary methods.
6. Dimitri Principle (LOP): an object should have as little knowledge of other objects as possible. A class is called by a mediation class instead of directly calling another class.
Pros: Reduce coupling, disadvantage: Increase code complexity and reduce operational efficiency.
7. Combination/Aggregation multiplexing principle (CARP): prioritize the use of combination/aggregation to make the system more flexible, followed by inheritance, to achieve reuse.
Benefit: The combination multiplexing requires less dependency, the combination is dynamic during program run time, and the new object can dynamically reference the same object as the constituent object. Cons: Using a combination/combination will generate more objects that need to be managed.
Object-Oriented design principles