Six principles of design pattern: single responsibility principle

There are six principles in design mode: Interface isolation

Six principles of design pattern: dependency inversion principle

Six principles of design pattern: Richter’s substitution principle

There are six principles of design patterns: Demeter’s Law

Six principles of design pattern: open and close principle

Interface Segregation Principle

1. A client should not rely on interfaces it does not need

2. Dependencies between classes should be built on the smallest interface

Don’t put too many methods in an interface. This will make the class look bloated. Interfaces should be as detailed as possible, one interface corresponds to one function module, and the methods in the interface should be as few as possible to make the interface more flexible and portable. Some might think that the interface isolation principle is similar to the single responsibility principle, but there are significant differences. The single responsibility principle is a division of business logic that focuses on responsibility. The interface isolation principle is based on interface design considerations. For example, an interface contains 10 method, the duty of the 10 methods are placed in the same interface, and provides multiple modules calls, but the method of different modules need to rely on is not the same, the module in order to achieve its function will have to implement some of its meaningless method, the design is not in line with the interface segregation principle. The interface isolation principle requires “as many specialized interfaces as possible” dedicated to different modules.

Source: www.cnblogs.com/az4215/p/11…