Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
VOL. 38,
NO. 1,
JANUARY/FEBRUARY 2012
INTRODUCTION
case is not isolated; other research also rests on unsupported or weakly supported foundations.
Without strong foundations for refactoring research, we
can have only limited confidence that research built on
these foundations will be valid in the larger context of realworld software development. As a step toward strengthening these foundations, this paper revisits some of the
assumptions and conclusions drawn in previous research.
Our experimental method takes data from eight different
sources (described in Section 2) and applies several
different analysis strategies to them. The contributions of
our work lie in both the experimental method and in the
conclusions that we are able to draw:
The RENAME refactoring tool is used much more
frequently by ordinary programmers than by the
developers of refactoring tools (Section 3.1).
. About 40 percent of refactorings performed using a
tool occur in batches (Section 3.2).
. About 90 percent of configuration defaults in
refactoring tools are not changed when programmers use the tools (Section 3.3).
. Messages written by programmers in version-control commit logs do not reliably indicate the presence
of refactoring in the commit (Section 3.4).
. Programmers frequently floss refactor, that is, they
interleave refactoring with other types of programming activity (Section 3.5).
. About half of refactorings are not high level, so
refactoring detection tools that look exclusively for
high-level refactorings will not detect them (Section 3.6).
. Refactorings are performed frequently (Section 3.7).
. Close to 90 percent of refactorings are performed
manually, without the help of tools (Section 3.8).
. The kind of refactoring performed with a tool differs
from the kind performed manually (Section 3.9).
In Section 4, we discuss the interaction between these
conclusions and the assumptions and conclusions of other
researchers.
.
VOL. 38,
TABLE 1
Refactoring Tool Usage in Eclipse
Some tool logging began in the middle of the Toolsmiths and Mylyn data collection (shown in light gray) and after the Users data collection (denoted
with a *). The - symbol denotes a percentage corresponding to a fraction for which the denominator is zero.
VOL. 38,
TABLE 2
The Median Number of Explicitly Batched Elements
Used for Several Refactoring Tools, Where n Is the
Number of Total Uses of That Refactoring Tool
3.3
manually after the refactoring may be easier than configuring the tool. In the past, we have found some limited
evidence that programmers perform only a small amount of
configuration of refactoring tools. When we conducted a
small survey in September 2007 at a Portland Java Users
Group meeting, eight programmers estimated that, on
average, they supply configuration information only 25 percent of the time.
To validate this hypothesis, we counted how often
programmers used various configuration options in the
Toolsmiths and Mylyn data when performing the five
refactorings most frequently performed by Toolsmiths.
We skipped refactorings that did not have configuration
options. The results of the analysis are shown in Table 3.
Configuration Option refers to a configuration parameter
that the user can change. Default Value refers to the
default value that the tool assigns to that option. Change
Frequency refers to how often a user used a configuration
option other than the default. The data suggest that
refactoring tools are configured infrequently: The overall
mean change frequency for these options is about 10 percent
in Toolsmiths and 12 percent in Mylyn. Although different
configuration options are changed from defaults with
varying frequencies, almost all configuration options that
we inspected were below the average configuration percentage predicted by the Portland Java Users Group survey.
This analysis has several limitations. First, we could not
count how often certain configuration options were
changed, such as how often parameters are reordered when
EXTRACT METHOD is performed. Second, we examined
only the five most-common refactorings; configuration may
be more frequent for less popular refactorings. Third, we
measured how often a single configuration option is
changed, but not how often any configuration option is
changed for a refactoring. Fourth, we were not able to
distinguish between the case where a developer purposefully used a nondefault configuration option and the case
TABLE 3
Refactoring Tool Configuration in Eclipse
where she blindly used the nondefault option left over from
the last time that she used the tool.
TABLE 4
Refactoring between Commits in Eclipse CVS and Mylyn CVS
Plain numbers count commits in the given category; tuples contain the number of refactorings in each commit.
10
VOL. 38,
Fig. 3. Refactorings over 40 sessions for Mylyn (at left) and 40 sessions for Eclipse (at right). Refactorings shown include only those with tool support
in Eclipse.
11
12
TABLE 5
Refactoring Level Percentages in Four Data Sets
VOL. 38,
13
TABLE 6
Distribution of Number of Tool Refactorings Per Week
from 39,729 Tool-Using Developers Collected
from 395,814 Weeks with Development Activity
3.9
14
DISCUSSION
VOL. 38,
and other environments, will suit the majority of, but not all,
refactoring situations. In addition, our findings about the
batching of refactorings provides evidence that tools that
force the programmer to repeatedly select, initiate, and
configure can waste programmers time. This was in fact one
of the motivations for Murphy-Hill and Blacks refactoring
cues, a tool that allows the programmer to select several
program elements for refactoring at one time [8].
Questions still remain for researchers to answer. Why is
the RENAME refactoring tool so much more popular than
other refactoring tools? Why do some refactorings tend to
be batched while others do not? Moreover, our experiments
should be repeated in other projects and for other
refactorings to validate our findings.
15
16
CONCLUSIONS
VOL. 38,
ERRATA
APPENDIX A
NORMALIZATION PROCEDURE
In Section 3.5, we discussed a normalization procedure for
some reported data. To explain the procedure we used for
calculating, well give the intuitive explanation and an
example calculation below:
We wish to estimate how many pure-refactoring commits were made to CVS. Recall that previously we sampled
20 Labeled projects and 20 Unlabeled projects, and we
know that six Labeled commits were pure refactoring and
zero Unlabeled commits were pure refactoring. Naively, we
might simply do the addition (6 0) and divide over the
total commits to get the estimate: 6=40 15%. However,
this is a good estimate for our sample, but a bad estimate for
the population as a whole because our 20-20 sample was
drawn from two unequal strata. Specifically, in this naive
estimate, we are giving too much weight to the six purerefactoring commits because Labeled commits only account
for about 10 percent of total commits. So what do we do?
Instead of the naive approach, we normalize our estimate
for the relative proportions of Labeled (10 percent) to
Unlabeled commits (90 percent). The following calculation
gives the normalized result:
.
.
.
.
APPENDIX B
SURVEY
The following e-mail template describes a survey sent to
people who developed code for the Mylyn and Toolsmiths
data sets. In this template, XXX was instantiated with the
developers first name. YYY was instantiated with either
Mylyn or Eclipse, depending on which project the
developer worked on. ZZZ.refactoringname was instantiated with a transaction number and a refactoring name,
DD/MM/YYYY indicates when that refactoring was
checked in to CVS, and some comment was instantiated
with the comment that the developer made when checking
in to CVS.
Subject: Your thoughts on our refactoring study
Dear XXX,
My colleagues Chris Parnin, Andrew Black, and I are
completing a study about refactoring and refactoring tool
use. We investigated two case studies of refactoring, one of
which was of the YYY project, of which you were a
committer. In short, our analysis compared your refactoring
tool history (produced when you used the Eclipse refactoring
tools) with what we inferred as refactoring in the code when
you committed to CVS. From this, we made estimates about
how often people refactor, what kinds of refactoring tools
they use, and when they use or do not use refactoring tools.
We are hoping you will answer a few questions about
your thoughts on issues related to your refactoring. We
hope this will provide some insights into how we can
interpret our results. You are one of less than 10 people that
we are inviting to participate, so your comments are
extremely valuable to us.
Below, you will find several interview questions; we
anticipate that they will take around 15 minutes to complete
in total. Unless you indicate otherwise, we would like to
reserve the right to summarize or repeat your answers
verbatim in our forthcoming paper. As for privacy, in the
paper we do not personally identify developers by name or
by CVS username (although we do say which projects we
analyzed). You can respond to this questionnaire simply by
replying to this email.
Because we are on a tight publishing deadline, if you
choose to participate, we would appreciate your response
by February 25th.
Sincerely,
Emerson Murphy-Hill, The University of British Columbia
Chris Parnin, Georgia Institute of Technology
Andrew P. Black, Portland State University
17
Rename
Extract Local Variable
Inline
Extract Method
Move
Change Method Signature
Convert Local To Field
Introduce Parameter
Extract Constant
Convert Anonymous To Nested
Move Member Type to New File
Pull Up
Encapsulate Field
18
Extract Interface
Generalize Declared Type
Push Down
Infer Generic Type Arguments
Use Supertype Where Possible
Introduce Factory
Extract Superclass
Extract Class
Introduce Parameter Object
Introduce Indirection
Would you like a copy of the paper when it is
complete?
ACKNOWLEDGMENTS
The authors thank Barry Anderson, Christian Bird, Tim
Chevalier, Danny Dig, Thomas Fritz, Markus Keller, Ciaran
Llachlan Leavitt, Ralph London, Gail Murphy, Suresh
Singh, and the Portland Java Users Group for their
assistance, as well as the US National Science Foundation
for partially funding this research under CCF-0520346.
Thanks to the anonymous reviewers and the participants of
the Software Engineering seminar at the University of
Illinois Urbana-Champaign for their excellent suggestions.
VOL. 38,
REFERENCES
[1]
[2]
[3]
[4]
[5]
[6]
[7]
[8]
[9]
[10]
[11]
[12]
[13]
[14]