Refactoring is the use of small transformations to restructure code without changing any program behavior. Just as you factor an expression to make it easier to understand or modify, you refactor code to make it easier to read, simpler to understand, and faster to update. And just as a refactored expression must produce the same result, the refactored program must be functionally equivalent with the original source.
Some common motivations for refactoring code include:
The IDE’s refactoring features simplify code restructuring by evaluating the changes that you want to make, showing you the parts of your application that are affected, and making all necessary changes to your code. For example, if you use the Rename operation to change a class name, the IDE finds every usage of that name in your code and offers to change each occurrence of that name for you.
Refactor Menu
When you use the IDE’s refactoring operations, you can change the structure of your code and have the rest of your code updated to reflect the changes you have made.
Refactoring operations are available on the Refactor menu (see Refactor Menu).
Undoing/Redoing Refactoring Changes
![]() |
Undo - The IDE rolls back all the changes in all the files that were affected by the refactoring. |
![]() |
Redo - The IDE repeats the refactoring changes in all the files that were affected. |
If any of the affected files have been modified since the refactoring took place, the refactoring Undo/Redo is not available.
Finding Function Usages
You can use the Find Usages command to determine each place a function is used in your project’s source code.
To find where a function is used in your project:
The Usages window displays the file name and the line of code for each usage found in that file.
To jump to a specific occurrence of the function, do one of the following actions:
Additional IDE Find Mechanisms
The other IDE tools that enable you to search for all the places where specific text is used in a project include:
To find where a function is declared in a source file, you can double click the function in the Navigator window. If the function is declared in a different source file, right click the function and choose Navigate>Go To Declaration from the contextual menu.
Renaming a Function or Parameter
To rename a function or parameter and update references to it throughout your project:
For quick in-place renaming, place the cursor in the item that you want to rename and press Ctrl-R. Then type the new name. To finish renaming, press Escape.
Moving, Copying and Safely Deleting C Code
These functions are specific to C++ code. See Refactor Menu.