What is Refactoring?
Refactoring may be a new term to many MPLAB users since many PIC microcontroller programs are very short. However, as applications grow more complex, IDE support for refactoring becomes very useful.
Code Refactoring is the process of changing a computer program's source code without modifying its external functional behavior in order to improve some of the nonfunctional attributes of the software. Advantages include improved code readability and reduced complexity to improve the maintainability of the source code, as well as a more expressive internal architecture or object model to improve extensibility. (Source: Wikipedia)
In a sense, refactoring is a fancy form of "search and replace" where the IDE is laguage aware and can make more intelligent decisions about how and when an item should be modified. While "search and replace" might be adequate for renaming a variable when you only have one or a very small number of source files, it becomes more of a challenge if you have a large program and want to move an item to a new file or rename something throughout your entire project. Refactoring is immensely helpful in situations like that.
The simplest form of refactoring is to rename a variable or function. This may be accomplished by highlighting the variable or function in your code and then selecting from the main menu Refactor ▸ Rename…. This will open a dialog box prompting you for a new name. At this point, you may accept the new name by clicking on the Refactor button and the IDE will rename every instance of the variable or function in all files of the project. Alternatively, you may choose to preview the refactoring by clicking on the Preview button and control individual items as to whether or not they should be renamed.
The preview window will open as a new tab in the output area. Here you can see each file in which the variable or function exists and will be renamed, with a before and after view of the code on the right side. A checkmark indicates that a specific instance will be renamed. Unchecking it will keep the original name for that specific instance. Click on the Do Refactoring button to accept the rename operation and any modifications to individual instances you have made.
Move refactoring is only applicable to object oriented languages and is used to move a class from one package to another. This is not usable in C or assembly at the present time.
Copy refactoring is only applicable to object oriented languages and is used to copy the contents of a class from one package to another. This is not usable in C or assembly at the present time.
Safely Delete Operations
Savely Delete refactoring is only applicable to object oriented languages and is used to delete a class member variable while checking to ensure that it is not used by your code. This is not usable in C or assembly at the present time.