RAD Studio (Common)
ContentsIndex
PreviousUpNext
Refactoring: Extracting Method
To extract a method:

  1. In the Editor, open the class or interface containing the code fragment that you wish to extract.
  2. Place the mouse cursor in the desired fragment of source code. Refactoring determines the beginning and the end of the relevant statement.
  3. On the main menu, choose RefactoringExtract Method
    Tip: Alternatively, right-click the code fragment and choose Refactoring->Extract Method
    on the context menu.
  4. In the dialog box that opens, specify the following information:
    • Name of the new method
    • Visibility (public, protected, private, internal, internal protected)
    • Header comment
    • Whether the method is Static.
  5. Click OK to complete the extraction and create the new method.
    Tip:
    • When applying Extract Method, parameters and local variables in the selected code fragment become the parameters of the new method.
    • The code fragment cannot contain a return statement of the original method. An error message displays if you attempt to include a return statement in the code fragment.
    • The code fragment cannot modify more than one single local variable. An error message displays if you violate this restriction.
    • If the selected code fragment is repeated in several locations, it is your responsibility to replace these fragments in the appropriate locations with the proper method calls.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!