ISP (interface segregation principle), interface isolation principle
The requirements are as follows:
① The dependence of one class on another class should be established on the minimum interface.
② It is better to use multiple special interfaces than to use a single total interface.
③ Unrelated interfaces cannot be merged into a bloated large interface.
④ A bloated large interface should be divided into several suitable small interfaces.
Interface separation method:
1. Use the delegate separation interface: delegate requests to the Implementation classes of other interfaces to fulfill the required responsibilities.
2. Use multiple inheritance and separation interfaces: implement multiple interfaces to fulfill the required responsibilities.
Summary:
Large interfaces lead to unnecessary Coupling Relationships between customer programs. The interface is designed according to the interface isolation principle, and the large interface is decomposed so that the customer program only depends on the method it needs. In terms of design, the interface is easy to maintain and highly reusable.
ISP (interface segregation principle), interface isolation principle