1Single responsibility principle
Concept: for a class, there should be only one reason for its change.
If a class takes too many responsibilities, it is equal to coupling these responsibilities together, and a change of responsibility may weaken or suppress the ability of the class to perform other responsibilities. This coupling can lead to fragile design, and when changes occur, the design will suffer unexpected damage.
2The principle of opening and closing
Concept: open for expansion, and closed for change.
No matter how close the module is, there are some changes that cannot be closed. Since it is not completely closed, the designer must choose the type of change that the module it involves. He must first guess the most likely variety, and then construct abstract to isolate the changes.
It is assumed that changes do not occur when code is written. When changes occur, we create abstractions to isolate similar changes in the future. In the face of requirements, changes to programs are done by adding new code, rather than changing existing code.
The principle of opening and closing is the core of object-oriented design. Following this principle can bring huge benefits that object oriented technology claims: maintainability, scalability, reusability and flexibility. Developers should only abstract the parts that show frequent changes in the program, but, for each part of the application,Deliberately abstracting is not a good idea. It is equally important to reject immature abstraction and abstraction itself.
3Dependence Inversion Principle
AHigh level modules should not rely on low – level modules. The two should be abstracted.
BAbstraction should not rely on details, and details should rely on abstraction.
Dependency inversion can be said to be an object oriented design, which is not important in which language programming is used, and if it is written for abstract programming rather than detailed programming, all of the dependencies in the program are terminated in the abstract class or interface, that is, object oriented design.
4The substitution principle of the Richter
Subtypes must be able to replace their parent types.