Seven main object-oriented design principles
Opening and closing principles : In the face of demand, changes to the program is done by adding new code , rather than changing the original title
dependency Reversal Principle : High-level modules should not rely on the underlying modules, two should be dependent on the abstract, the abstract should not rely on the details, the details should depend on the abstraction. So to programming for the interface , do not program for implementation.
The richter substitution principle : Because subclass objects can be used where the base class object is used, the base class type is used to define the object in the program, and then the subclass type is determined at run time, and the subclass object is substituted for the parent class object
Single Responsibility Principle : An object should contain only a single responsibility, and that responsibility is encapsulated completely in a class, in the case of a class, there should be only one reason for it to change
interface Isolation Principle: interface Isolation principle refers to the use of a number of specialized interfaces, rather than the use of a single total interface. each interface should assume a relatively independent role , not too much, do not do what should not be done, the matter should be done
Synthetic Reuse Principle : the principle of composite reuse is to use some existing objects in a new object to become part of the new object by means of association relations (including combinatorial relationships and aggregation relationships). The new object uses the method of delegating to invoke an existing object to reuse its existing function. In short: try to use a combination/aggregation relationship, using less inheritance
Dimitri Rule : A software entity should interact with other entities as little as possible . In the structure design of a class, each class should minimize the access rights of its member variables and member functions