1. Principle of single responsibility

Explanation: A class is responsible for defining only one function; There are no more than one cause for a class change, and if there are, the class is split.

2. Li substitution principle

Explanation: the subclass of the common part of the abstract to the parent class, subclass try not to overwrite or rewrite the parent class has been abstract method; In programming, try to define objects using base class types and then replace them with subclass types at run time.

3. Dependency inversion principle

Explanation: References to interfaces or abstractions should be made, not dependencies on concrete classes.

4. Demeter’s Rule (Least Know Rule)

Explanation: The less a class knows about a complex class, the better. It should encapsulate the logic part inside the method, expose the public method externally, and let the external class know the internal logic implementation as much as possible. Or encapsulate the use of complex classes into a common utility class method, which is provided externally, rather than directly referenced. The advantage of this is that when complex classes are modified, the original referenced classes are not affected too much.

5. Open and close principle

Explanation: A class should be designed to be open for extension and closed for modification.

6. Interface isolation principle

Explanation: There is no method for each interface that a subclass does not need to implement; if there is, the interface is split.

Supplement:

Demeter’s rule

Explanation: Coupling between classes is minimized;

As shown below: