Assessing the Refactorability of Software Clones
- 22 June 2015
- journal article
- Published by Institute of Electrical and Electronics Engineers (IEEE) in IEEE Transactions on Software Engineering
- Vol. 41 (11) , 1055-1090
Abstract
The presence of duplicated code in software systems is significant and several studies have shown that clones can be potentially harmful with respect to the maintainability and evolution of the source code. Despite the significance of the problem, there is still limited support for eliminating software clones through refactoring, because the unification and merging of duplicated code is a very challenging problem, especially when software clones have gone through several modifications after their initial introduction. In this work, we propose an approach for automatically assessing whether a pair of clones can be safely refactored without changing the behavior of the program. In particular, our approach examines if the differences present between the clones can be safely parameterized without causing any side-effects. The evaluation results have shown that the clones assessed as refactorable by our approach can be indeed refactored without causing any compile errors or test failures. Additionally, the computational cost of the proposed approach is negligible (less than a second) in the vast majority of the examined cases. Finally, we perform a large-scale empirical study on over a million clone pairs detected by four different clone detection tools in nine open-source projects to investigate how refactorability is affected by different clone properties and tool configuration options. Among the highlights of our conclusions, we found that (a) clones in production code tend to be more refactorable than clones in test code, (b) clones with a close relative location (i.e., same method, type, or file) tend to be more refactorable than clones in distant locations (i.e., same hierarchy, or unrelated types), (c) Type-1 clones tend to be more refactorable than the other clone types, and (d) clones with a small size tend to be more refactorable than clones with a larger size.Keywords
Funding Information
- European Union (European Social Fund—ESF)
- Greek national funds through the Operational Program
- National Strategic Reference Framework (NSRF)
- Thalis—Athens University of Economics
- Business—Software Engineering Research Platform
This publication has 52 references indexed in Scilit:
- Detecting differences across multiple instances of code clones2014
- Increasing clone maintenance support by unifying clone detection and refactoring activitiesInformation and Software Technology, 2012
- CloneDifferentiator: Analyzing clones by differentiation2011
- Code Clone Detection on Specialized PDGs with Heuristics2011
- NICAD: Accurate Detection of Near-Miss Intentional Clones Using Flexible Pretty-Printing and Code Normalization2008
- Comparison and Evaluation of Clone Detection ToolsIEEE Transactions on Software Engineering, 2007
- GPLAG2006
- Clone Detection Using Abstract Syntax Suffix Trees2006
- Clone detection using abstract syntax trees2002
- CCFinder: a multilinguistic token-based code clone detection system for large scale source codeIEEE Transactions on Software Engineering, 2002