RAD Studio (Common)
ContentsIndex
PreviousUpNext
Refactoring Applications

Refactoring is a technique you can use to restructure and modify your code in such a way that the intended behavior of your code stays the same. RAD Studio provides a number of refactoring features that allow you to streamline, simplify, and improve both performance and readability of your application code.

Name 
Description 
RefactorImport Namespace
Use this dialog box to import namespaces into the using clause of your code file based on objects in code that are contained in that namespace, but for which no namespace has yet been declared.  
Refactoring is a technique you can use to restructure and modify your existing code in such a way that the intended behavior of your code stays the same. Refactoring allows you to streamline, simplify, and improve both performance and readability of your application code.
Each refactoring operation acts upon one specific type of identifier. By performing a number of successive refactorings, you build up a large transformation of the code structure, and yet, because each refactoring is limited to a single type of object or operation, the margin of error is small. You can always back out of a particular... more 
RefactorChange Params
Adds, edits, removes, and rearranges the parameters of a method.  
Renames identifiers and all references to the target identifier. You can rename an identifier if the original declaration identifier is in your project or in a project your project depends on, in the Project Group. You can also rename an identifier if it is an error identifier, for instance, an undeclared identifier or type.
The refactoring engine enforces a few renaming rules:
  • You cannot rename an identifier to a keyword.
  • You cannot rename an identifier to the same identifier name unless its case differs.
  • You cannot rename an identifier from within a dependent project when the project where the original... more 
Use the Add Parameter or Edit Parameter dialog box to add a parameter to a method signature or to edit a parameter that you have already added.  
Use the Extract Method refactoring operation to change a code fragment into a method whose name describes the purpose of the method. The Extract Method feature analyzes any highlighted code. If that code is not extractable to a method, the refactoring engine warns you. If the method can be refactored, the refactoring engine creates a new method outside of the current method. The refactoring engine then determines any parameters, generates local variables, determines the return type, and prompts the user for a new name. The refactoring engine inserts a method call to the new method in the location of the... more 
RefactorDeclare Field
Use this dialog box to declare a field in your code.  
Extracting resource strings helps centralize string definitions which can then be more easily translated, if necessary. You can extract string values to resource strings that are defined in the resourcestring section of your code file. If there is no resourcestring section in your code, the refactoring engine creates one following either the implementation keyword or the uses list.
You cannot create a resource string from the following elements:
  • Constants. For example, const A = 'abcdefg'; cannot be extracted to a resource string.
  • Constants in Parameters. For example, in MyProc(A, B:Integer; C: string='test'); the string cannot be extracted to a resource... more 
You can use the Refactoring feature to create variables and fields. This feature allows you to create and declare variables and fields while coding without planning ahead. This topic includes information about:
  • Declare Variable
  • Initial Type Suggestion
  • Declare Field
 
RefactorDeclare Variable
Use this dialog box to declare a local variable in a procedure. If the cursor in the Code Editor is not positioned on an undeclared variable, the RefactorDeclare Variable command in unavailable.  
RefactorExtract Method
Turns a selected code fragment into a method. RAD Studio moves the extracted code outside of the current method, determines the needed parameters, generates local variables if necessary, determines the return type, and replaces the code fragment with a call to the new method.  
Sometimes, you may not want to change code, but want to find references to a particular identifier. The refactoring engine provides Find References, Find Local References, and Find Declaration Symbol commands.
Both Find References and Find Local References commands provide you with a hierarchical list in a separate Find References window, showing you all occurrences of a selected reference. If you choose the Find References command, you are presented with a treeview of all references to your selection in the entire project. If you want to see local references only, meaning those in the active code file, you... more 
Adding or removing a parameter from a function is a commonly performed and tedious programming task. RAD Studio provides the Change Parameters refactoring to automate this task. You can use Change Parameters to add, remove, and rearrange function parameters.
To use this refactoring, select a function name in the Code Editor and choose RefactorChange Params.
When you use the Change Parameters refactoring, the following function signature conflicts can occur:
  • A descendant class contains an override for the function you are refactoring. When you refactor the function, any functions that override the refactored function will also be refactored.
  • A... more 
RefactorExtract Resource String
Use this dialog box to convert the string currently selected in the Code Editor to a resource string. The resourcestring keyword and the resource string will be added to the implementation section of your code, and the original string will be replaced with the new resource string name.  
RefactorFind Unit
Use this dialog to locate units and add them to the uses clause of your Delphi code file.  
Sync Edit mode allows you to change all occurrences of an identifier when you change one instance of that identifier. When you enter Sync Edit mode, you can tab to each highlighted identifier in your current Code Editor window. If you change an identifier that appears elsewhere in the file, all occurrences transform to whatever you type, character by character. 
ViewRefactorings
Performs the listed refactorings.  
The refactoring engine takes advantage of a versioning mechanism, known as local striping, to allow you to undo renames in source code files. The IDE records the current timestamp of each file included in the current refactoring changeset. The timestamp corresponds to a specific local revision of the file. When you select the undo command, the IDE copies the local backup file that matches that timestamp back over the refactored file.
The important point to understand is that any changes that you make to the files after the refactoring will also be rolled back when you perform an Undo.... more 
RefactorRename
Use this dialog box to specify a new name for the selected symbol before refactoring your code.  
RefactorRename <symbol name>
Use this dialog box to perform rename refactoring on a symbol, such as a variable, type, field, method, or parameter, currently selected in the Code Editor. The first field in the dialog varies based on the type of symbol you are renaming.  
RefactorRename <symbol name>
Use this dialog box to perform rename refactoring on a symbol, such as a variable, type, field, method, or parameter, currently selected in the Code Editor. The first field in the dialog varies based on the type of symbol you are renaming.  
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!