SOLID Principles¶
SOLID principles of object-oriented programming:
SRP OCP LSP ISP DIP
SOLID 原则:
1. SRP 单一职责原则
2. OCP 开闭原则
3. LSP 里式替换原则
4. ISP 接口隔离原则
5. DIP 依赖倒置原则
The SOLID concepts are:
1. SRP: The Single-responsibility principle:
"There should never be more than one reason for a class to change."
In other words, every class should have only one responsibility.
2. OCP: The Open–closed principle:
"Software entities ... should be open for extension, but closed for modification."
3. LSP: The Liskov substitution principle:
"Functions that use pointers or references to base classes must be able to
use objects of derived classes without knowing it".
See also design by contract.
4. ISP: The Interface segregation principle:
"Many client-specific interfaces are better than one general-purpose interface."
5. DIP: The Dependency inversion principle:
"Depend upon abstractions, [not] concretions.