Design patterns learning principles -1 seven designs

Opening and closing principles:
open for extension, but closed for modification.
When changing needs of the application, without modifying the source code of a software entity or binary code, you can extend the functionality of the modules, to meet the new demand.

Richter Substitution Principle:
subclass can extend the functionality of the parent class, but can not change the parent class of the original function.

Dependency Inversion principle:
high-level modules should not depend on low-level modules, both of which should rely on its abstract; abstract should not rely on the details, the details should depend on the abstract.
That reduces the coupling between the client and the implementation module.

Single Responsibility Principle:
Single Responsibility principles laid down a class should have one and only one cause why it changes, otherwise the class should be split.

Interface segregation principle:
the different interfaces in different modules.

Demeter (minimum knowledge of principles):
From the perspective of dependent persons, it should rely only dependent objects.
From the perspective of those who are dependent on that method should be exposed exposure only.

Synthesis of multiplexing principles:
to make use of a combination, less inheritance reuse.
Here Insert Picture Description
The seven principles of software design principles is a design pattern must try to follow the different requirements of the various principles of focus. Among them, the opening and closing principle is a general program, it tells us to open for extension, but closed for modification; Richter substitution principle tells us not to destroy the inheritance hierarchy; Dependency Inversion Principle tells us to be oriented programming interface; Single Responsibility Principle tells us achieve class to duty single; Interface Segregation principle tells us to streamline the design of the interface when single; Demeter tells us to reduce the coupling; synthetic multiplexing principle tells us to be preferentially used in combination or aggregation relationship multiplexing, less inheritance reuse .

Reference: http://c.biancheng.net/view/1333.html

Published 57 original articles · won praise 3 · Views 6207

Guess you like

Origin blog.csdn.net/qq_39830579/article/details/101844171