There are three main types of refactoring for Java code:
Renaming method refactoring mode, introducing explanatory variable reconstruction mode, replacing temporary variable reconstruction mode with query
Renaming Method Refactoring mode recommends performing the following steps to complete :
1. Create a method with a new name
2. Copy the method of the old method into the new method
3. The method that speaks the old method is modified to invoke the new method
4. Modify all references to the old method to refer to the new method
5. Delete old methods
The introduction of explanatory variable refactoring mode steps is relatively simple, as follows:
1. Declare a local variable and initialize it as part of the expression that needs to be replaced
2. For complex expressions, replace the parts that need to be replaced with a new local variable
3. Repeat this procedure for other parts of the expression
The steps to replace a temporary variable refactoring pattern with a query are as follows:
1. Find local variables that have been assigned only once
2. Declare the local variable final and recompile (to ensure that the variable is indeed only assigned once)
3. Copy the expression to the right of the equal sign of an assignment statement and modify it to a method body of a new method
4. Change the right of the equal sign of an assignment statement to a call to a new method
5. Replace all use of this local variable with a call to a new method
6. Delete Assignment statements and declarations for local variables