This article is participating in the Java Theme Month – Java Debug Notes Event, see the event link for details

  1. Extract Method extract method

    Put your code in a separate function and let the function name explain what the function does

  2. Pull up field (332)

    Both subclasses have the same field, move that field to the superclass.

  3. Extract class extract class

    A class does what two classes should do, creating a new class and moving related fields and functions from the old class to the core class.

  4. Move Method Move method

    In a program, a function communicates more with another class than it resides in, calls the latter, is called by the latter, creates a new function in the class that the function refers to most often, turns the old function into a pure delegate function, or removes the old function altogether.

  5. Encapsulate Field Encapsulate field

    Declare it private and provide access functions accordingly. Security issues. If you don’t encapsulate properties in an object that are modified elsewhere, the user of the object is unaware of that.

  6. Move Field Move field

    The same meaning as 4.

  7. Duplicated code (76)

  8. Form Template method creates a template function.

    You have subclasses of functions that perform similar operations in the same order, but differ in the details of each operation.

    Put these operations into separate functions and keep them all signed the same. So the original function becomes the same, so we move the original function up to the superclass.

    When called, the original function in the superclass is called, and the subclass is polymorphically specified.

    The Template Method in the design pattern focuses on the order. (The template method mode is used to export edi messages in the project I am doing now)

  9. Substitute Algorithm (139)

    Replace the function body with another algorithm (note that if determines a fixed number of values can be put into a set 139)

  10. Replace Temp with query Replace temp with query

    Your program stores the result of an expression in a temporary variable, distills the expression into a separate function, replaces all reference points of the temporary variable with calls to the new function, and then the new function can be called by other functions.

  11. Split temporary variable Splits temporary variables

    A temporary variable in your program is amplified more than once. It is neither a loop variable nor used to collect the result of the calculation. For each assignment, an opposing, corresponding temporary variable is created (final).

  12. Intriduce Paramter object (295)

    Some parameters will naturally occur at the same time, and an object will replace those parameters. (e.g. StartDate, endDate)

  13. Preserve whole object (288)

    You take values from an object, pass them as arguments to a function call, and pass the whole object instead.

  14. Replace method with Method Object (135)

    You have a large function, and the use of local variables prevents you from extracting the function, putting the function into a single object, so that the local variable becomes a field in the object, and then you can break the large function into smaller functions in the same object.

  15. Decompose Conditional conditions expression (238)

    There is a complex conditional expression statement that extracts separate functions from the if then else paragraphs. (Each equal sign has a specific meaning, indicated by the function name)

  16. Extract interfact extract interfact

    Several customers use the same subset of the class interface, or the interfaces of two classes have the same department, refining the same subset into a separate interface. (Interfaces make up for inheritance, and it is also possible to understand interface classes and implementation classes by inheritance.)

  17. Long Parameter List Indicates the Long parameter list

    Too long argument class makes it hard to understand. Too many parameters can be inconsistent, difficult to use, and you’ll have to modify them as soon as you need more data.

  18. Inline class Inlines a class (154)

    Move all the features of a class to another class without doing much, then remove the original class. As opposed to refining classes.