Refactoring is the process of changing the structure of a program while maintaining all of its functionality.

Testing your code is very important when refactoring. Because refactoring changes the structure of your code, you must make sure that the resulting code functions the same way as the code did before the refactoring.

Physical Structure


Renames a Java element


Used to move elements from one place to another.

Change Method Signature

The Change Method Signature refactoring is able to change parameter names, parameter types, the parameter order, the return type, and the method’s visibility. Parameters can also be added or removed.

Convert Anonymous Class to Nested

An anonymous class allows you to instantiate a class implementing an abstract class or interface without having to give it a name.

Class Level Structure

Push Down

The Push Down refactoring moves selected methods and fields from a class to all the classes that directly extend it. Any methods that are pushed down can optionally be left as an abstract declaration. A Push Down refactoring can be useful for restructuring the design of a project.

Pull Up

It involves moving selected methods and fields between classes. The Pull Up refactoring, however, moves methods and fields from a class to one of its superclasses.

Extract Interface

The Extract Interface refactoring allows you to create an interface from an existing class. You are able to select which methods from the current class will be included in the interface.

Structure inside a Class


The Inline refactoring takes a reference to a method, static final field, or a local variable and replaces it with its code or value. For example, if you inline a method call, the call will be replaced by the body of code in the called method.

Extract Method

If a method does more than one distinct operation, is too long, or if some code in a method is used several times, it may be beneficial to extract a section of the method into its own method.

Extract Local Variable

Extract Constant

Using a variable instead of an expression can have several benefits. It may increase performance if the same expression is used in several places and it can also make the code easier to read and understand.

Introduce Parameter

Introduce Parameter creates a new parameter in a method and then replaces an instance of a field or local variable with the new parameter.

Introduce Factory

A factory is a method which creates a new object and then returns that object.

Encapsulate Field

To use proper object orientated coding practices, you should make your fields private and
then create accessors and mutators to access the fields.

Convert Local Variable to Field

The Convert Local Variable to Field refactoring moves a declaration of a variable from inside a method to the top of the class where it is then visible to the entire class.

AOP refactoring


Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.