Object-oriented design principles: seven Principles
1, single duty principle SRP
Definition: Every class in a system should have only one responsibility
Benefits: cohesion, low coupling
2, open and closed principle OCP
Definition: Open for extension, close for modification
Benefits: Adaptability and flexibility, stability and continuity, reusability and maintainability
3, Richter replacement principle LSP
Definition: Wherever the parent class appears, it can be replaced with its subclasses without affecting the function
4, dependency inverted principle dip
Definition: High-level modules should not rely on the underlying modules, both should rely on their abstraction;
Abstraction should not depend on detail; detail should depend on abstraction.
Benefits: Improve the stability of the program, maintainability, scalability.
5, interface isolation principle ISP
Definition: Using multiple specialized interfaces is better than using a single total interface.
Benefit: Do not force new features to implement unwanted approaches
6, Dimitri Principle lop
Definition: An object should have as little knowledge of other objects as possible
Benefits: Reduced COUPLING
Disadvantages: Reduced communication efficiency, resulting in a large number of intermediary classes
7, combination/aggregation multiplexing principle carp
Definition: Preferential use of the combination to make the system more flexible, followed by the consideration of inheritance, to achieve the purpose of reuse
Benefit: Fewer dependencies are required for composite multiplexing
Composite multiplexing can be performed dynamically during run time
Cons: The system will have more objects to manage
Object-oriented design patterns