The Single-Responsibility Principle (SRP)
A class should have only one reason to change.
单一职责原则(SRP)
一个类应该仅有一个引起它变化的原因。
The Open/Closed Principle (OCP)
Software entities (classes, modules, functions, etc.) should be open for extension but closed for modification.
开放封闭原则(OCP)
软件实体(类,模块,函数等等)应该是对扩展开放的,对修改封闭的。
The Liskov Substitution Principle (LSP)
Subtypes must be substitutable for their base types.
Liskov替换原则(LSP)
子类型必须能够替换掉它们的基类型。
The Interface Segregation Principle (ISP)
Clients should not be forced to depend on methods they do not use.
接口隔离原则(ISP)
不应该强迫客户依赖于它们不用的方法。
The Dependency-Inversion Principle (DIP)
A.High-level modules should not depend on low-level modules. Both should depend on abstractions.
B.Abstractions should not depend upon details. Details should depend upon abstractions.
依赖倒置原则(DIP)
A. 高层模块不应该依赖于低层模块。二者都应该依赖于抽象。
B. 抽象不应该依赖于细节。细节应该依赖于抽象。
The Least Knowledge Principle (LKP)
Talk only to your immediate friends.
迪米特原则(LoD)又称 最少知识原则(LKP)
只和你的密友谈话。就是说一个对象应当对其他对象尽可能少的了解