General principles of interface design

In C, some complexity is reduced by using functions and procedures (functions that function without returning a value are called procedures). Interfaces provide a similar function, but at a higher level. A function is what allows the program that accesses it to perform a function. An interface is what gives its clients access to a set of functions with abstract behavior. The degree to which an interface simplifies programming depends largely on its design. The challenge of constructing an interface is the design of the interface, not the coding!

The general interface design should have the following characteristics:

  • Identity An interface should define an abstraction consistent with a well-defined subject, and if a function does not fit into that subject, then it should not be included in that subject.
  • Simplicity The real value of an interface lies not in revealing something, but in hiding something. Simple and intuitive for customers to use.
  • Sufficiency The interface should have sufficient and sufficient functionality.
  • Generality When you design an interface for a library, you must forget about the application that first reminded you of making the tool, and design such a tool for the most common, likely users.
  • Stability No matter how the implemented methods change, functions defined in an interface must maintain exactly the same structure and function. Interfaces cannot be easily changed.

2018.05.05 00:31

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325815698&siteId=291194637