Some API design experience, write it down, and use it to evaluate the newly written code in the future
Basic:
- The API name is self-describing;
- A single function, targeting the dimension of change, not the smallest function;
- If the speed of synchronous execution is too slow, consider providing two interfaces for asynchronous execution and queryable results (or provide callback function)
parameter:
- The parameter name is used as a supplement to the API and is self-describing;
- The parameters are kept at least exposed for easy expansion;
- The value range of the field, use meaningful words, and disable numbers such as 0, 1, and 2;
return value:
- (Negotiable) Two descriptors are required: the success/failure of the call status, and the success/failure of the execution result;
- Returning the error code is not as good as returning the error text description, after all, failure is failure;