Refactoring Overview
Go Up to Refactoring Applications Index
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 the performance and readability of your application code.
Each refactoring operation acts upon one specific type of identifier. By performing a number of successive refactoring operations, 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 refactoring if you find that it gives you an unexpected result.
Each refactoring operation has its own set of constraints. For example, you cannot rename symbols that are imported by the compiler. These are described in each of the specific refactoring topics. In Delphi refactoring operations can be applied to identifiers used with generics.
RAD Studio includes a refactoring engine that evaluates and executes the refactoring operation. There are two engines: one inbuilt (for Delphi) and one powered by Visual Assist (for C++). The engine also displays a preview of what changes will occur in the Refactorings pane that appears at the bottom of the Code Editor. The potential refactoring operations are displayed as tree nodes, which can be expanded to show additional items that might be affected by the refactoring operation if they exist. Warnings and errors also appear in this pane.
You can access the refactoring tools from the Search and Refactor menus and from the context menus (right-click to activate the menu) of the Code Editor and of the Modeling's Diagram View or Model View.
Delphi Refactoring Tools
Find Symbols menu contains the following tools related to Searching:
- Find Symbols
- Go to Definition and Go to Implementation
The following refactoring operations are accessible only from the Code Editor and the Refactor menu:
- Rename
- Declare Variable
- Declare Field
- Extract Method
- Extract Resource String
- Change Parameters
- Find Unit
- Undo renaming operations
- Find References
- Sync Edit Mode
In the Code Editor or in Diagram View and Model View for Modeling, you can use the following refactoring operations:
- Moving members
- Extracting interfaces
- Extracting superclass
- Pull members up and Push members down
- Safe Delete
- Creating inline variables
- Introducing fields
- Introducing variables
- Previewing refactoring operations in Refactorings pane
C++ Refactoring Tools
You can access the refactoring tools from the Search and Refactor menus. Also, you can access the context menus (right-click to activate the menu) of the Code Editor.
You can find the following tools in the Code Editor and the Search menu:
Besides, you can access some other refactoring tools through the Code Editor and the Refactor menu, such as: