A function needs to obtain more information from the caller.Add an object parameter to this function to bring the object into the required information of the function.
Motivation: Add parameter is a common refactoring technique. The motivation for using this refactoring is simple: you must modify a function, and the modified function requires information that is not available in the past. Therefore, you need to add a parameter to the function.
It should be noted that the timing of this reconstruction is not used. In addition to adding parameters, you often have other options. If possible, other options are better than adding parameters because they do not increase the length of the parameter column. Too long parameter columns are bad becauseProgramIt is hard for a Member to remember so many parameters and long parameter columns are often accompanied by bad taste: Data clumps ).
Take a look at the existing parameters and ask yourself: Can you get the required information from these parameters? If the answer is no, is it possible to provide the required information through a function? Where do you actually use this information? Should this function belong to the object with this information? Take a look at the existing parameters. Is it appropriate to add new parameters? Maybe you should consider using introduce parameter object (introducing the parameter object ).
Method: 1. Check whether the function signature has been implemented by a superclass or subclass. If yes, perform the following steps for each implementation.
2Declare a new function with the same name as the original function, but add new parameters. ConvertCodeCopy to the new function.
3, Compile.
4Modify the old function to call the new function.
5, Compilation, and testing.
6Find all reference points of the function. Modify all of them to reference the new function. After each modification, compile the test.
7And delete old functions.
8, Compilation, and testing.