Recommending Clones for Refactoring Using Design, Context, and History

Authors: Wei Wang Michael W. Godfrey

Venue: ICSME   2014 IEEE International Conference on Software Maintenance and Evolution, pp. 331-340, 2014

Year: 2014

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.

BibTeX:

@inproceedings{weiwang2014rcfrudcah,
    author = "Wei Wang and Michael W. Godfrey",
    title = "Recommending Clones for Refactoring Using Design, Context, and History",
    year = "2014",
    pages = "331-340",
    booktitle = "Proceedings of 2014 IEEE International Conference on Software Maintenance and Evolution"
}

Plain Text:

Wei Wang and Michael W. Godfrey, "Recommending Clones for Refactoring Using Design, Context, and History," 2014 IEEE International Conference on Software Maintenance and Evolution, pp. 331-340