Refactoring

Visual Studio has amazing refactoring capabilities. This feature removes most of the drudgery of manual refactoring, making it almost a trivial task. I remember the mind-numbing challenge of updating variable names that were spread across dozens of source files. Even more, I remember the errors created from the tedium of refactoring a large application manually. Most likely I would abandon, revert back to the original, and enjoy a cup of coffee at the local café. Now even the most ambitious refactoring goals are simply a wizard away. In this quick-fix environment, it is easy to forget that automatic refactoring can touch a vast amount of code in an instant with unexpected results. With manual refactoring, you are present at every change. Worst case scenario: I may make an error every few minutes—almost all of them are noticed immediately. Automatic refactoring is a press of a button, and you can create hundreds of problems in an instant. None of them you see.

If the project has hundreds of source files, some not written by you, refactoring can be particularly a problem. Ironically, the more automatic refactoring may benefit you (i.e., the larger the project), the larger the possibility of abuse. This is the conundrum. For this reason, some companies have banned automatic refactoring altogether. I am not advocating something quite that drastic. However, I am advocating testing. For even the most innocuous refactoring, test and retest your application for improper changes that you may not be unaware of. If there are only a few changes, then ask to be prompted with each change. You will have the ability to review or reject each change, which is considerably safer.

No change is too minor to test. There are too many stories of the innocent change, the one that could not possibly harm an application, haunting a developer to the end of his or her days. If you change the name of a single variable, retest the application. If you change a class member from private to public, or vice versa, retest your application. If you change the [fill in the blank] in your application, retest the program.

Tip

Tip

Refactoring, even when trivial, requires retesting the application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.174.191