The typical object-oriented principles can be divided into two categories: class-oriented and package-oriented.
Class-oriented includes: srp--single responsibility principle.
ocp--Open closure principle.
LSP--The principle of the Richter replacement.
dip--dependency Inversion principle.
isp--interface Isolation principle.
Package-oriented include: The emphasis is on the cohesion of the package design requirements->rep--reuse publishing equivalence principle.
ccp--the principle of common closure.
crp--Common reuse principle.
For the inter-package coupling requirement, the->adp--principle of non-cyclic dependence is required.
spp--the principle of stable dependence.
sap--Stable abstract principle.
Six major design principles:
Single duty principle srp--Responsibility Principle: A class should have only one reason for change.
A class should have only one cause for it to change, and do not encapsulate responsibilities that vary in reason and should be separated.
Key points: What is the responsibility of the class and how to divide the responsibilities of the class.
For interfaces, the design must be single, but for the implementation of the class requires more considerations, a single responsibility for
interface, class, and also apply to methods, a method to do as much as possible, for the single responsibility of the principle of recommendation is the interface must do
To a single duty, the class is designed to do as much as possible for only one cause to change.
Open closure principle Ocp--open Closed Principle: Software entities (classes, modules, functions, etc.) should be extensible but cannot be modified.
Software entities should be open to extensions and closed for modifications.
Dependency inversion principle dip--dependence inversion Principle: Abstractions should not be dependent on detail, and detail should be dependent on abstraction.
Rely on abstraction instead of relying on specifics because abstractions are relatively stable.
Interface Isolation principle Isp--interface segregation Principle: Customers should not be forced to rely on unused methods, the interface belongs to the customer and does not belong to
The class hierarchy in which it resides.
As far as possible the application of specialized interfaces, rather than a single total interface, the interface should be user-oriented to establish a dependency on the smallest interface.
Richter Replacement principle LSP Liskov substitation Principle: subtypes must be able to replace their base types.
Dimitri Rule LOD Law of Demeter: Also known as the least-known principle, refers to software entities should be as few as possible with other software entities interaction.
C # design pattern: Six design principles