NET Refactor - Extract ObjectIn the process of refactoring, you want to simplify the structure of your code. If you want to extract a block of code and create a new method from it (Extract Method), and the block of code is referencing a number of variables, you might want to create a Structure or Class to encapsulate the variables. You could then pass only a reference to the Structure or Class, instead 5-10 or more variables.
The Extract Object feature of NET Refactor provides the functionality to automatically create a Structure or Class and change the references within the method to the new object. To use the feature, select the block of variables that you wish to encapsulate, and click the Extract Object option on the Rename menu. When you do this, the dialog shown below will be displayed.

To create an object, Stucture or Class, you must enter the name of the object and a name for the instance variable for the object. The instance varaible will replace the selected variables as they will be moved to and encapsulated by the new object.
To create a Structure, fill the two text boxes and click the Save Button. The selected variables will be replaced in the method by the instance variable. Any references to the original variables will be qualified by the name of the instance variable. The new Structure will be placed immediately above the original method.
To create a Class, click the Class check box. You will then have a choice as to where to place the new class. If you check the New File check box, a new file, by the name of the class name, will be added to the project. If you leave the New File check box unchecked, the new class will be placed immediately above the class containing the method from which the variables were extracted.
Try NET Refactor Free for 30 days or purchase now by clicking Download or Purchase.
New Features are being added to NET Refactor, Version 2, and as they are added, you can download the new features without additional cost.
To view additional detail about NET Refactor, you can view the help file for NET Refactor on-line, by clicking Show Help File.
Top of Page
|