"Cloning considered harmful" considered harmful: patterns of cloning in software

  • Authors:
  • Cory J. Kapser;Michael W. Godfrey

  • Affiliations:
  • Software Architecture Group (SWAG) David R. Cheriton School of Computer Science, University of Waterloo, Waterloo, Canada;Software Architecture Group (SWAG) David R. Cheriton School of Computer Science, University of Waterloo, Waterloo, Canada

  • Venue:
  • Empirical Software Engineering
  • Year:
  • 2008

Quantified Score

Hi-index 0.00

Visualization

Abstract

Literature on the topic of code cloning often asserts that duplicating code within a software system is a bad practice, that it causes harm to the system's design and should be avoided. However, in our studies, we have found significant evidence that cloning is often used in a variety of ways as a principled engineering tool. For example, one way to evaluate possible new features for a system is to clone the affected subsystems and introduce the new features there, in a kind of sandbox testbed. As features mature and become stable within the experimental subsystems, they can be migrated incrementally into the stable code base; in this way, the risk of introducing instabilities in the stable version is minimized. This paper describes several patterns of cloning that we have observed in our case studies and discusses the advantages and disadvantages associated with using them. We also examine through a case study the frequencies of these clones in two medium-sized open source software systems, the Apache web server and the Gnumeric spreadsheet application. In this study, we found that as many as 71% of the clones could be considered to have a positive impact on the maintainability of the software system.