Identification of extract method refactoring opportunities for the decomposition of methods

被引:122
作者
Tsantalis, Nikolaos [1 ]
Chatzigeorgiou, Alexander [1 ]
机构
[1] Univ Macedonia, Dept Appl Informat, Thessaloniki 54006, Greece
关键词
Extract Method refactoring; Program slicing; Module decomposition; PROGRAM; COMPLEXITY; GRAPH; CODE; FLOW;
D O I
10.1016/j.jss.2011.05.016
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
The extraction of a code fragment into a separate method is one of the most widely performed refactoring activities, since it allows the decomposition of large and complex methods and can be used in combination with other code transformations for fixing a variety of design problems. Despite the significance of Extract Method refactoring towards code quality improvement, there is limited support for the identification of code fragments with distinct functionality that could be extracted into new methods. The goal of our approach is to automatically identify Extract Method refactoring opportunities which are related with the complete computation of a given variable (complete computation slice) and the statements affecting the state of a given object (object state slice). Moreover, a set of rules regarding the preservation of existing dependences is proposed that exclude refactoring opportunities corresponding to slices whose extraction could possibly cause a change in program behavior. The proposed approach has been evaluated regarding its ability to capture slices of code implementing a distinct functionality, its ability to resolve existing design flaws, its impact on the cohesion of the decomposed and extracted methods, and its ability to preserve program behavior. Moreover, precision and recall have been computed employing the refactoring opportunities found by independent evaluators in software that they developed as a golden set. (C) 2011 Elsevier Inc. All rights reserved.
引用
收藏
页码:1757 / 1782
页数:26
相关论文
共 51 条
[1]  
ABADI A, 2008, P 2 ACM WORKSH REF T
[2]  
AHO V, 1986, COMPILERS PRINCIPLES
[3]  
Allen M., 2003, SIGPLAN Notices, V38, P284, DOI 10.1145/966049.777394
[4]  
BALL T, 1993, P 1 INT WORKSH AUT A, P206
[5]   SOFTWARE COMPLEXITY AND MAINTENANCE COSTS [J].
BANKER, RD ;
DATAR, SM ;
KEMERER, CF ;
ZWEIG, D .
COMMUNICATIONS OF THE ACM, 1993, 36 (11) :81-94
[6]   INFORMATION-FLOW AND DATA-FLOW ANALYSIS OF WHILE-PROGRAMS [J].
BERGERETTI, JF ;
CARRE, BA .
ACM TRANSACTIONS ON PROGRAMMING LANGUAGES AND SYSTEMS, 1985, 7 (01) :37-61
[7]  
Binkley D., 1996, ADV COMPUTERS, V43
[8]   Tool-supported refactoring of existing object-oriented code into aspects [J].
Binkley, David ;
Ceccato, Mariano ;
Harman, Mark ;
Ricca, Filippo ;
Tonella, Paolo .
IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, 2006, 32 (09) :698-717
[9]  
Cimitile A, 1996, J SOFTW MAINT-RES PR, V8, P145, DOI 10.1002/(SICI)1096-908X(199605)8:3<145::AID-SMR127>3.0.CO
[10]  
2-9