1> single Responsibility Principle
This is the most common design principle of our design program. For example, user information, attributes and behaviors, basic information belongs to the attribute class, and execution belongs to the behavior class or interface, in actual projects, most of them can only be used in this place.
2> Lee's replacement principle
Avoid the negative reconstruction effects of inheritance relationships as much as possible
Notes:
2.1 when calling other classes, try to use interfaces or parent classes of other classes as much as possible, which is also our regular habit.
2.2 If the Child class cannot fully implement the parent class method or the parent class method has a ambiguity in the Child class, disconnect the Parent-Child inheritance relationship and switch to dependency, aggregation, and combination associations, in general, when the sub-class and parent class attributes or actions may have elements and methods that do not have an inheritance relationship, create a parent class to do specific things, the newly created parent class must have a dependency or other associations with the original parent class, which is often used by spring or hibernate in the framework.
3> Dependency inversion principle
The straightforward point of dependency inversion is to make the business interface as much as possible and adopt interface-based programming to reduce the maintenance and expansion costs. It is a good principle method for parallel development, interface-based programming is a common practice in large-scale distributed systems.
4> interface isolation principle
Based on the actual project, we try to separate as many business-defined interfaces as possible to facilitate single business customization and avoid the loss of system performance caused by design defects.
5> Demeter's Law
Make business code cohesion as much as possible to reduce external exposure.
6> Open and Close principles
Rewrite the parent class method as much as possible without modifying the parent class.
Design Model-six principles application scenarios Popular edition (1)