4.3.2 Extended Low-level refactorings

 

The purpose of program refactorings is to reduce costs of program development. The low level refactorings can be extended with some useful transformations which will reduce the user interaction. Some of those extended transformations can be replaced with a combination of simple low-level transformations.

Example: Move-transformation can be replaced with copy- and delete- transformations. Rename-transformation can be replaced with two move-transformations.

 

4.3.2.1 Abstract transformations

 

Abstract transformations change the type of entity to abstract. Entity can be a class or a method. This kind of refactoring can be very useful in order to avoid duplicated code in a program, to reduce the size of a class or to generalize class, or method implement-ations.

 

4.3.2.1.1 Abstract class

 

Description:   Transformation changes class type to abstract.

Conditions:    1) Class exists and is not an interface or already abstract

2)  Class is not instantiated in the program

DPT:               1) DPT checks the condition.

2)  DPT does not check the condition.

    Reason: DPT-Parser can't resolve all instances of a class(especially internal) correctly

Parameters:    String (full class name)

Output:           String (class name). Output can be used in composite-transformation.

Program:        Behavior does not change if condition is accomplished.

 

4.3.2.1.2 Abstract method

 

Description:   Transformation changes the type of the method to abstract.

Conditions:    1) Class is not interface and has this method.    

(minor)            2) Class is abstract(if not - it should be abstract!) 

(minor)            3) Class has subclasses with references to this method 

DPT:               1) DPT checks the condition.

                        2) DPT prompts user for the next step if condition is not accomplished

                        3) DPT does not check the condition.

Parameters:    String (full method name)

Output:           String (new method). Output can be used in composite-transformation.

Program:        Behavior does not change if condition is accomplished.

 

4.3.2.2 Move transformations

 

Move refactorings move an entity from one owner to a new owner. This transformation can be replaced with "copy and remove" transformations. The purpose of this kind of refactoring is to reduce the user interaction.

 

4.3.2.2.1 Move class

 

Description:   Transformation will move an existing class to a target package

Conditions:    1) Target package exists and does not have this class.

                        2) Program does not have references to this class.

                        3) Class does not have current package-specific internal references.

DPT:               1) DPT checks the condition.

2) DPT checks the condition.

                        3) If the condition not accomplished DPT prompts the user for next step.

Parameters:    String (target package), String (class name)

Output:           String (new class). Output can be used in composite-transformation.

Program:        New unreferenced class with no instance will be added to program. 

                        An unreferenced class will be removed. Behavior does not change.

 

4.3.2.2.2Move method

 

Description:   Transformation will move an existing method to target class

Conditions:    1) Target class exists and does not have this method.    

2)  Program does not have references to this method.

(minor)            3) Method is abstract and target class is not (or interface)

4) Method does not have current class-specific internal references.

DPT:               1) DPT checks the condition.

2)  DPT does not check the condition.

3)  DPT will prompt user if this condition is not accomplished.

4)  DPT does not check the condition.

                        Reason: DPT-Parser can't resolve all references to this member correctly

Parameters:    String (target class), String (full method name)

Output:           String (new method).Output can be used in composite-transformation.

Program:        New method will be added to class. Unreferenced method will be removed.

 Behavior does not change if condition is accomplished.

 

4.3.2.2.3 Move variable

 

Description:   Transformation will move an existing variable to the target class

Conditions:    1) Target class exists and does not have this variable.   

                        2) Program does not have references to this variable.

DPT:               1) DPT checks the condition

2) DPT does not check the condition.

                        Reason: DPT-Parser can't resolve all references to this member correctly

Parameters:    String (target class), String (full variable name)

Output:           String (new variable).Output can be used in composite-transformation.

Program:        Variable will be added to class. An unreferenced variable will be

                        removed. Behavior does not change if condition is accomplished.

 

 

4.3.2.3 Rename transformations

 

Rename transformations change the name of an entity. This transformation can be replaced with move-transformations. The entity can be a class, a variable or a method.

 

4.3.2.3.1 Rename class

 

Description:   Transformation will rename an existing class.

Conditions:    Program does not have references to this class.

DPT:               DPT checks the condition.

Parameters:    String (full class name)

Output:           String (new class ).Output can be used in composite-transformation.

Program:        New  unreferenced class with no instance will be added to the program. 

An unreferenced class will be removed. Behavior does not change.

 

4.3.2.3.2 Rename method

 

Description:   Transformation will rename an existing method.

Conditions:    1) Class exists and has this method.      

                        2) Program does not have references to this method.                

DPT:               1) DPT checks the condition.

                        2) DPT does not check the condition.

            Reason: DPT-Parser can't resolve all references to this member correctly

Parameters:    String (full method name)

Output:           String (new method). Output can be used in composite-transformation.

Program:        New method will be added to class. Unreferenced method will be

removed. Behavior does not change if condition is accomplished.

 

4.3.2.3.3 Rename variable

 

Description:   Transformation will rename an existing variable

Conditions:    1) Class exists and has this variable.     

                        2) Program does not have references to this variable.

DPT:               1) DPT checks the condition.

                        2) DPT does not check the condition.

            Reason: DPT-Parser can't resolve all references to this member correctly

Parameters:    String (full variable name)

Output:           String (new variable).Output can be used in composite-transformation.

Program:        Variable will be added to class. An unreferenced variable will be

                        removed. Behavior does not change if condition is accomplished.