Home  //  Tools  //  Refactoring Browser  //  Refactorings

The refactorings in the Refactoring Browser can be classified into three sections: class based refactorings, method based refactorings, and code based refactorings. The class based refactorings operate on classes, instance variables, and class variables and are defined off the class menu. The method based refactorings are defined off the selector menu. Finally the code based refactorings operate on individual statements and are available through the context sensitive menus in the code tool. Many of the class based refactorings are also available in the context sensitive menus in the code tools.

Class Refactorings

  1. Create subclass: This refactoring allows you to insert a new class into an existing hierarchy. For example, you can insert a new class between object and all of its subclasses by using the refactoring (although I wouldn't recommend it). To use the refactoring, simple select the superclass for the new class and then execute the create subclass refactoring.
  2. Rename: This refactoring renames a class and also renames every reference to the class in the code. Even symbols with the same name as the class will also be renamed so that "Smalltalk at: ..." will work. However, if you are constructing class names using the asSymbol message, then those strings will not be renamed. In ENVY the renamed class will also contain all the stored ENVY attributes that the original class contained, including the classes part builder records in VA. However, currently the browser does not rename class references in these stored attributes.
  3. Safe Remove: This refactoring checks for references to a class, and if there are no references, it will remove the class. If you reference the class by using constructed symbols and "Smalltalk at: ...", it may remove your class even though your code still uses it.
  4. Convert to Sibling: ...
  5. Add instance/class variable: Add a variable to the class. In ENVY it will check that the variable is not already defined as a temporary in one of the class' methods.
  6. Rename instance/class variable: Renames a variable and all references to the variable. If you are using instVarAt:'s, then this might break your code, since currently the new variable's name is always at the end.
  7. Remove instance/class variable: Removes a variable only if it is not referenced. Again, if you are using instVarAt:'s, this refactoring can remove a variable that is actually used.
  8. Push Down instance/class variable: Moves a variable definition from the currently selected class to only those subclasses that use the variable (removing the variable if no subclass has a reference to the variable). This will only be allowed, if the selected class contains no references to the variable. For class variables, it can only push the variable down into one subclass. Otherwise, it will have split the one class variable into two and possibly broken the code. As will the other variable refactorings, this refactoring will not work with instVarAt:'s.
  9. Pull Up instance/class variable: Move a variable definition from a subclass of the currently selected class into the currently selected class.
  10. Create instance/class variable Accessors: Creates getter and setter methods for a variable. The methods are named with the name of the variable. If a method with that name already exists, then it will add a number to the name, until it no longer conflicts.
  11. Abstract instance/class variable: Performs the create accessors refactoring and then converts all direct variable to use the accessor methods.
  12. Protect/Concrete instance variable: Converts all variable accessor sends to direct variable references. If the accessor is no longer used then it will be removed.
  13. Convert to ValueHolder: This refactoring is only available for VW. It will convert a variable into a ValueHolder. This was more useful for converting old interfaces used in OW4.1 to the new VW style.

Method Refactorings

  1. Move to Component: Moves a method to another object (defined by an argument or instance variable).
  2. Rename: Renames all implementors of a method, all senders, and all symbols references. In addition to strict renaming, it also allows you to rearrange the parameters. However, when rearranging the parameters, it cannot permute any symbols that are performed.
  3. Safe Remove: Removes a method if there are no senders of the method or there are no symbol that reference the method name. Also, it will remove a method if it is equivalent to the superclass' definition.
  4. Add Parameter: Adds a default parameter to all implementors of the method.
  5. Inline all Self Sends: Inlines all senders within the class of the method. If there are no more senders after all inlines have been performed, then it will remove the method.
  6. Push Up: Pushes a method up into the superclass. If the superclass is abstract and already defines the method, then the superclass' method will be copied down into the other subclasses (assuming they don't already define the method).
  7. Push Down: Pushes a method down into all subclasses that don't implement the method. This can only be allowed if the class is abstract.

Code Refactorings

  1. Extract Method: Extracts the selected code as a separate method. This refactoring determines what temporary variables are needed in the new method, and prompts for a selector that takes these arguments.
  2. Inline Temporary: Removes the assignment of a variable and replaces all references to the variable with the right hand side of the assignment.
  3. Convert to Instance Variable: Converts a temporary into an instance variable.
  4. Remove Parameter: Removes an unused parameter from all implementors of the method, and removes it from the message sends.
  5. Inline Parameter: Remove a parameter from the method, and adds an assignment at the beginning of the method. This can only be performed if all senders of the method have the same value for the parameter.
  6. Rename Temporary: Renames a temporary variable.
  7. Move to Inner Scope: Moves a temporary variable definition into the tightest scope that contains both the variable assignment and references. This is useful for converting unoptimized blocks into optimized ones.
  8. Extract to Temporary: Extracts a message into an assignment statement. For example, if you have something like

           self someMessage anotherMessage foo: 1 bar: 2 


    You can extract "self someMessage" to a temporary named, "temp", and get:

            | temp |
            temp := self someMessage.
            temp anotherMessage foo: 1 bar: 2

  9. Inline Message: Inlines a message send. If there are multiple implementors of the message, it will prompt for the implementation that should be inlined.
 
If you have any comments or suggestions, Contact Us.

Refactory Profile

 
The Refactory, Inc. and its consultants provide top notch on-site training and consulting services. Through our combined years of industry and academic experience, the principals of The Refactory base our consultation on proven practices backed by industry leading research. We have the skills, experience and ambition to make your project successful.

Company Info

7 Florida Drive Urbana, IL 61801
Phone: 1-217-239-2633
Email: This email address is being protected from spambots. You need JavaScript enabled to view it.