The interface here refers to the interaction between the client and the interface, rather than the user interface.
Client: refers to the Client in the broad sense, that is, the consumer of the interface.
Interface: refers to an interface in a broad sense, that is, a class or interface that provides consumption.
Interface Design Principles: simple and clear
1. The fewer interfaces on the interface, the better. More classes should be encapsulated in the interface, that is, the "High Cohesion and low coupling" that is often described in the module design"
2. the more direct the operation steps, the better. Do not use too many step conventions or implied
3. on the premise of a single thread, the interface should be closed as a whole, that is, an interface should be consumed and released in a timely manner.
4. Forward call or callback should be used on the premise of a single thread, and reverse call should not be used to ensure that the interface is not messy.
* Forward call: interface of the client call interface
* Reverse call: The interface calls the client interface.
5. For application-level development, some interface restrictions should be imposed on the GOF design mode to avoid dealing with too many classes on the client.
In layman's terms:
1. Hide implementation details;
2. Only provide necessary functions;
3. Do not influence external code; ---------------------- disable reverse calls
4. Maintain a unified interface style;
5. Allocate and release resources at the same level;
6. detect errors at a lower level and handle errors at a higher level.