Empirical Software Engineering

, Volume 23, Issue 2, pp 693–770 | Cite as

Is cloned code really stable?

  • Manishankar Mondal
  • Md Saidur Rahman
  • Chanchal K. Roy
  • Kevin A. Schneider


Clone has emerged as a controversial term in software engineering research and practice. The impact of clones is of great importance from software maintenance perspectives. Stability is a well investigated term in assessing the impacts of clones on software maintenance. If code clones appear to exhibit a higher instability (i.e., higher change-proneness) than non-cloned code, then we can expect that code clones require higher maintenance effort and cost than non-cloned code. A number of studies have been done on the comparative stability of cloned and non-cloned code. However, these studies could not come to a consensus. While some studies show that code clones are more stable than non-cloned code, the other studies provide empirical evidence of higher instability of code clones. The possible reasons behind these contradictory findings are that different studies investigated different aspects of stability using different clone detection tools on different subject systems using different experimental setups. Also, the subject systems were not of wide varieties. Emphasizing these issues (with several others mentioned in the motivation) we have conducted a comprehensive empirical study where we have - (i) implemented and investigated seven existing methodologies that explored different aspects of stability, (ii) used two clone detection tools (NiCad and CCFinderX) to implement each of these seven methodologies, and (iii) investigated the stability of three types (Type-1, Type-2, Type-3) of clones. Our investigation on 12 diverse subject systems covering three programming languages (Java, C, C#) with a list of 8 stability assessment metrics suggest that (i) cloned code is often more unstable (change-prone) than non-cloned code in the maintenance phase, (ii) both Type 1 and Type 3 clones appear to exhibit higher instability than Type 2 clones, (iii) clones in Java and C programming languages are more change-prone than the clones in C#, and (iv) changes to the clones in procedural programming languages seem to be more dispersed than the changes to the clones in object oriented languages. We also systematically replicated the original studies with their original settings and found mostly equivalent results as of the original studies. We believe that our findings are important for prioritizing code clones from management perspectives.


Code clones Code stability Software maintenance and evolution 


  1. Aversano L, Cerulo L, Penta MD (2007) How clones are maintained: an empirical study. In: Proc CSMR, pp 81–90Google Scholar
  2. Bakota T, Ferenc R, Gyimothy T (2007) Clone smells in software evolution. In: Proc ICSM, pp 24–33Google Scholar
  3. Barbour L, Khomh F, Zou Y (2011) Late propagation in software clones. In: Proc ICSM, pp 273–282Google Scholar
  4. Barbour L, Khomh F, Zou Y (2013) An empirical study of faults in late propagation clone genealogies. J Softw Evol Process 25(11):1139–1165CrossRefGoogle Scholar
  5. Bettenburg N, Shang W, Ibrahim W, Adams B, Zou Y, Hassan A (2009) An empirical study on inconsistent changes to code clones at release level. In: Proc WCRE, pp 85–94Google Scholar
  6. Cai D, Kim M (2011) An empirical study of long-lived code clones. In: Proc FASE/ETAPS, pp 432–446Google Scholar
  7. Chatterji D, Carver JC, Kraft NA (2016) Code clones and developer behavior: results of two surveys of the clone research community. Empir Softw Eng 21(4):1476–1508CrossRefGoogle Scholar
  8. Cordy JR, Roy CK (2011) The NiCad Clone Detector. In: Proc ICPC (Tool Demo Track), pp 219–220Google Scholar
  9. Göde N, Harder J (2011) Clone Stability. In: Proc CSMR, pp 65–74Google Scholar
  10. Göde N, Koschke R (2009) Incremental clone detection. In: Proc CSMR, pp 219–228Google Scholar
  11. Göde N, Koschke R (2010) Studying clone evolution using incremental clone detection. JSME 25(2):165–192Google Scholar
  12. Göde N, Koschke R (2011) Frequency and risks of changes to clones. In: Proc ICSE, pp 311–320Google Scholar
  13. Harder J, Göde N (2013) Cloned code: stable code. J Softw Evol Process 25(10):1063–1088CrossRefGoogle Scholar
  14. Higo Y, Kusumoto S (2009) Significant and scalable code clone detection with program dependency graph. In: Proc WCRE, pp 315–316Google Scholar
  15. Hordijk W, Ponisio M, Wieringa R (2009) Harmfulness of code duplication—a structured review of the evidence. In: Proc EASE, pp 88–97Google Scholar
  16. Hotta K, Sano Y, Higo Y, Kusumoto S (2010) Is duplicate code more frequently modified than non-duplicate code in software evolution?: an empirical study on open source software. In: Proc EVOL/IWPSE, pp 73–82Google Scholar
  17. Islam JF, Mondal M, Roy CK (2016) Bug replication in code clones: an empirical study. In: Proc. SANER, pp 68–78Google Scholar
  18. Jarzabek S, Xu Y (2010) Are clones harmful for maintenance? In: Proc IWSC, pp 73–74Google Scholar
  19. Juergens E, Deissenboeck F, Hummel B, Wagner S (2009) Do code clones matter? In: Proc ICSE, pp 485–495Google Scholar
  20. Kamiya T, Kusumoto S, Inoue K (2002) CCFinder: a multilinguistic token-based code clone detection system for large scale source code. TSE 28(7):654–670Google Scholar
  21. Kapser C, Godfrey MW (2008) “Cloning considered harmful” considered harmful: patterns of cloning in software. ESE 13(6):645–692Google Scholar
  22. Kim M, Sazawal V, Notkin D, Murphy GC (2005) An empirical study of code clone genealogies. In: Proc ESEC-FSE, pp 187–196Google Scholar
  23. Krinke J (2007) A study of consistent and inconsistent changes to code clones. In: Proc WCRE, pp 170–178Google Scholar
  24. Krinke J (2008) Is cloned code more stable than non-cloned code? In: Proc SCAM, pp 57–66Google Scholar
  25. Krinke J (2011) Is cloned code older than non-cloned code? In: Proc IWSC, pp 28–33Google Scholar
  26. Li J, Ernst MD (2011) CBCD: cloned buggy code detector. University of Washington Department of Computer Science and Engineering technical report UW-CSE-11-05-02. Seattle, May 2, 2011. RevisedGoogle Scholar
  27. Lozano A, Wermelinger M (2008) Assessing the effect of clones on changeability. In: Proc ICSM, pp 227–236Google Scholar
  28. Lozano A, Wermelinger M (2010) Tracking clones’ imprint. In: Proc IWSC, pp 65–72Google Scholar
  29. Lozano A, Wermelinger M, Nuseibeh B (2007) Evaluating the harmfulness of cloning: a change based experiment. In: Proc MSR, p 18Google Scholar
  30. Mondal M, Rahman MS, Saha RK, Roy CK, Krinke J, Schneider KA (2011) An empirical study of the impacts of clones in software maintenance. In: Proc ICPC student research symposium track, pp 242–245Google Scholar
  31. Mondal M, Roy CK, Rahman S, Saha RK, Krinke J, Schneider K A (2012a) Comparative stability of cloned and non-cloned code: an empirical study. In: Proc SAC, pp 1227–1234Google Scholar
  32. Mondal M, Roy CK, Schneider KA (2012b) An empirical study on clone stability. ACR 12(3):20–36Google Scholar
  33. Mondal M, Roy CK, Schneider KA (2012c) Dispersion of changes in cloned and non-cloned code. In: Proc IWSC, pp 29–35Google Scholar
  34. Mondal M, Roy CK, Schneider K (2014a) An insight into the dispersion of changes in cloned and non-cloned code: a genealogy based empirical study. SCP 95(4):445–468Google Scholar
  35. Mondal M, Roy CK, Schneider KA (2014b) Late propagation in near-miss clones: an empirical study. ECEASST 63:1–17Google Scholar
  36. Mondal M, Roy CK, Schneider K A (2015) A comparative study on the bug-proneness of different types of code clones. In: Proc ICSME, pp 91–100Google Scholar
  37. Mondal M, Roy CK, Schneider KA (2016) A comparative study on the intensity and harmfulness of late propagation in near-miss code clone. Softw Qual J 24(4):883–915CrossRefGoogle Scholar
  38. Rahman F, Bird C, Devanbu P (2010) Clones: what is that smell? In: Proc MSR, pp 72–81Google Scholar
  39. Rahman MS, Roy CK (2014) A change-type based empirical study on the stability of cloned code. In: Proc SCAM, pp 31–40Google Scholar
  40. Rahman MS, Aryani A, Roy CK, Perin F (2013) On the relationships between domain-based coupling and code clones: an exploratory study. In: Proc ICSE NIER track, pp 1265–1268Google Scholar
  41. Roy CK, Cordy JR (2008a) An empirical evaluation of function clones in open source software. In: Proc WCRE, pp 81–90Google Scholar
  42. Roy CK, Cordy JR (2008b) NICAD: accurate detection of near-miss intentional clones using flexible pretty-printing and code normalization. In: Proc ICPC, pp 172–181Google Scholar
  43. Roy CK, Cordy JR (2008c) Scenario-based comparison of clone detection techniques. In: Proc ICPC, pp 153–162Google Scholar
  44. Roy CK, Cordy JR (2009) A mutation/injection-based automatic framework for evaluating code clone detection tools. In: Proc mutation, pp 157–166Google Scholar
  45. Roy CK, Cordy JR, Koschke R (2009) Comparison and evaluation of code clone detection techniques and tools: a qualitative approach. SCP 2009(74):470–495MathSciNetzbMATHGoogle Scholar
  46. Roy CK, Zibran MF, Koschke R (2014) The vision of software clone management: past, present and future. In: Proc CSMR-18/WCRE-21 software evolution week, p 16Google Scholar
  47. Saha RK, Asaduzzaman M, Zibran MF, Roy CK, Schneider KA (2010) Evaluating code clone genealogies at release level: an empirical study. In: Proc SCAM, pp 87–96Google Scholar
  48. Saha RK, Roy CK, Schneider KA (2011) An automatic framework for extracting and classifying near-miss clone genealogies. In: Proc ICSM, pp 293–302Google Scholar
  49. Selim GMK, Barbour L, Shang W, Adams B, Hassan AE, Zou Y (2010) Studying the impact of clones on software defects. In: Proc WCRE, pp 13–21Google Scholar
  50. Thummalapenta S, Cerulo L, Aversano L, Penta MD (2009) An empirical study on the maintenance of source code clones. ESE 15(1):1–34Google Scholar
  51. Wang T, Harman M, Jia Y, Krinke J (2013) Searching for better configurations: a rigorous approach to clone evaluation. In: Proc ESEC/SIGSOFT FSE, pp 455–465Google Scholar
  52. Wang X, Dang Y, Zhang L, Zhang D, Lan E, Mei H (2012) Can I clone this piece of code here? In: Proc ASE, pp 170–179Google Scholar

Copyright information

© Springer Science+Business Media New York 2017

Authors and Affiliations

  • Manishankar Mondal
    • 1
  • Md Saidur Rahman
    • 1
  • Chanchal K. Roy
    • 1
  • Kevin A. Schneider
    • 1
  1. 1.Department of Computer ScienceUniversity of SaskatchewanSaskatoonCanada

Personalised recommendations