In the function method interface design related to the business, there are two types of function parameters:
1. Pass specific values, such as Save (int id, char name, char value ).
Advantage: when the number of parameters is small (less than three), it is easier to call and function parameters are relatively clear;
Disadvantage: it cannot adapt to the changing needs of the number of parameters;
2. pass through containers such as map, such as Save (hashmap m ).
Advantage: it can meet the changing needs of parameter types and numbers;
Disadvantage: it is not too intuitive for callers.
Summary
1. When the number of function parameters is less than three, the function business function is very simple. For example, it is reasonable to use the first method to obtain Objects Based on ID.
2. When there are more than three function parameters, different combinations of parameters are often transferred each time. The second method should be used for parameter transfer, in this case, calling a function is more convenient than using the first method, and can better adapt to subsequent business changes.
-By a farmer-