Recommending Clones for Refactoring Using Design, Context, and History
Authors:
- Wei WangWWWei Wang
- Michael W. GodfreyMGMichael W. Godfrey
- 1 September 2014
- conference paper
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- No. 10636773,p. 331-340
Abstract
Developers know that copy-pasting code (aka code cloning) is often a convenient shortcut to achieving a design goal, albeit one that carries risks to the code quality over time. However, deciding which, if any, clones should be eliminated within an existing system is a daunting task. Fixing a clone usually means performing an invasive refactoring, and not all clones may be worth the effort, cost, and risk that such a change entails. Furthermore, sometimes cloning fulfils a useful design role, and should not be refactored at al. And clone detection tools often return very large result sets, making it hard to choose which clones should be investigated and possibly removed. In this paper, we propose an automated approach to recommend clones for refactoring by training a decision tree-based classifier. We analyze more than 600 clone instances in three medium-to large-sized open source projects, and we collect features that are associated with the source code, the context, and the history of clone instances. Our approach achieves a precision of around 80% in recommending clone refactoring instances for each target system, and similarly good precision is achieved in cross-project evaluation. By recommending which clones are appropriate for refactoring, our approach allows for better resource allocation for refactoring itself after obtaining clone detection results, and can thus lead to improved clone management in practice.Keywords
This publication has 39 references indexed in Scilit:
- The vision of software clone management: Past, present, and future (Keynote paper)2014
- Automatic ranking of clones for refactoring through mining association rules2014
- Template-based reconstruction of complex refactorings2010
- Clone removal2010
- Clone-Aware Configuration Management2009
- Gathering refactoring data2008
- An Empirical Study of Function Clones in Open Source Software2008
- NICAD: Accurate Detection of Near-Miss Intentional Clones Using Flexible Pretty-Printing and Code Normalization2008
- Improving change descriptions with change contexts2008
- Tracking Code Clones in Evolving Software29th International Conference on Software Engineering (ICSE'07), 2007