Most refactoring tools let the programmer preview the changes before applying the refactoring. Usually, a refactoring preview window has two parts: an overview of the affected parts of the code and views of the changes to each part. The overview gives a high-level summary of parts of the code that the refactoring will affect. The programmer can browse the overview to examine the changes that are going to affect each part of the code. The following figures show how the preview windows of Eclipse, IntelliJ, and NetBeans look like.
The Eclipse (3.7.1) preview window for a Rename Field refactoring
The Eclipse (3.7.1) preview of a refactoring selected in the Quick Assist menu
The IntelliJ (11.0.1) preview window for a Rename refactoring
The NetBeans (7.1) preview window for a Rename refactoring
CodingSpectator recorded our participants' uses of the preview windows of the Eclipse refactoring wizards. Based on the data of CodingSpectator, the preview window got opened for only 2% of the refactorings that were performed using the refactoring wizard. Since the Eclipse refactoring tool sometimes forces the preview, our participants have opened the preview window for at most 2% of their automated refactorings. We also asked all of our interviewees who had used Quick Assist if they previewed their refactorings in the preview window of the Quick Assist menu. None of our interviewees had used the preview window of Quick Assist. These data show that our participants rarely previewed automated refactorings.
Some of our interviewees told us that they used the preview feature of the refactoring tool only when they were trying out a new automated refactoring. Based on our interviews, we found the following reasons for not using the preview window:
- Programmers are reluctant to use automated refactorings whose outcomes are hard to predict. If the automated refactoring is hard to predict and the programmers need to examine the preview closely, programmers are more likely to quit the tool and carry out the refactoring manually.
- Automated refactorings that programmers frequently use affect a small portion of the code and are easy to predict without previewing.
- The preview windows provide little useful context and too much information that overwhelms the programmers.
- Side-by-side views of code differences are not easy to read.
- When programmers perform a refactoring manually, they can evaluate the change gradually. However, if they use the preview window, there is a risk that they miss an important piece of change.
- It is an overhead to manage the preview windows. Programmers prefer to manage fewer windows and dialogs. Murphy-Hill et. al. had also reported that refactoring dialogs disrupt the programming workflow.
- Programmers are used to reading code in the source editor of the IDE because it provides many interactive features for browsing the code. The preview windows are not as interactive. Murphy-Hill et. al. had previously identified this problem with the preview window in a survey.