Skip to main content

A Duplicated Code Refactoring Advisor

  • Conference paper
  • First Online:
Agile Processes in Software Engineering and Extreme Programming (XP 2015)

Part of the book series: Lecture Notes in Business Information Processing ((LNBIP,volume 212))

Included in the following conference series:

Abstract

Refactoring is one of the key practices in Extreme Programming and other agile methods. Duplicated code is one of the most pervasive and pungent smells to remove from source code through refactoring. Duplicated code has been largely studied in the literature, and different types of duplications, or “clones”, have been identified. Some studies analyzed in details the problems caused by clones in the code, others outlined also the difficulties in removing clones, and the cases in which it could be better not removing them. The refactoring cost for removing clones can be very high, also due to the different choices on the possible refactoring steps. In this paper, we describe our approach and tool developed with the aim to suggest the best refactorings to remove clones in Java code. Our approach is based on the classification of the clones in terms of their location in a class hierarchy, and allows to choose among a restricted set of refactorings, which are then evaluated using multiple criteria. We provide a validation of the effectiveness of the approach.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Zibran, M.F., Roy, C.K.: The road to software clone management: A survey. Technical Report 2012–03, The Univ. of Saskatchewan, Dept. CS, February 2012

    Google Scholar 

  2. Roy, C.K., Cordy, J.R.: A survey on software clone detection research. Technical Report 2007–541, Sch. Computing, Queen’s Univ., Kingston, Canada, September 2007

    Google Scholar 

  3. Fowler, M.: Refactoring: Improving the Design of Existing Code. Addison-Wesley Longman Publishing Co. Inc., Boston (1999)

    MATH  Google Scholar 

  4. Roy, C.K., Cordy, J.R., Koschke, R.: Comparison and evaluation of code clone detection techniques and tools: A qualitative approach. Science of Computer Programming 74(7), 470–495 (2009). Special Issue on ICPC 2008

    Article  MathSciNet  MATH  Google Scholar 

  5. Golomingi Koni-N’Sapu, G.: Supremo – a scenario based approach for refactoring duplicated code in object oriented systems. Master’s thesis, Inst. of Computer Science, Faculty of Sciences, Univ. of Bern, June 2001

    Google Scholar 

  6. Roy, C., Cordy, J.: NICAD: accurate detection of near-miss intentional clones using flexible pretty-printing and code normalization. In: Proc. the 16th IEEE Int’l Conf. Program Comprehension (ICPC 2008), pp. 172–181. IEEE CS, Amsterdam (2008)

    Google Scholar 

  7. Tempero, E., Anslow, C., Dietrich, J., Han, T., Li, J., Lumpe, M., Melton, H., Noble, J.: The qualitas corpus: a curated collection of java code for empirical studies. In: Proc. the 17th Asia Pacific Software Eng. Conf., pp. 336–345. IEEE CS, Sydney, December 2010

    Google Scholar 

  8. Rattan, D., Bhatia, R., Singh, M.: Software clone detection: A systematic review. Information and Software Technology 55(7), 1165–1199 (2013)

    Article  Google Scholar 

  9. Giesecke, S.: Clone-based Reengineering für Java auf der Eclipse-Plattform. Diplomarbeit, Carl von Ossietzky Universität Oldenburg, Dept. für Informatik, Abteilung Software Eng., Germany (2003)

    Google Scholar 

  10. Giesecke, S.: Generic modelling of code clones. In: Koschke, R., Merlo, E., Walenstein, A. (eds.) Duplication, Redundancy, and Similarity in Software. Dagstuhl Seminar Proc., vol. 06301. Int’les Begegnungs- und Forschungszentrum für Informatik (IBFI), Germany (2007)

    Google Scholar 

  11. Higo, Y., Kusumoto, S., Inoue, K.: A metric-based approach to identifying refactoring opportunities for merging code clones in a java software system. J. Software Maintenance and Evolution: Research and Practice 20(6), 435–461 (2008)

    Article  Google Scholar 

  12. Arcelli Fontana, F., Zanoni, M., Ranchetti, A., Ranchetti, D.: Software clone detection and refactoring. ISRN Software Eng. 2013, 8 (2013)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Marco Zanoni .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2015 Springer International Publishing Switzerland

About this paper

Cite this paper

Arcelli Fontana, F., Zanoni, M., Zanoni, F. (2015). A Duplicated Code Refactoring Advisor. In: Lassenius, C., Dingsøyr, T., Paasivaara, M. (eds) Agile Processes in Software Engineering and Extreme Programming. XP 2015. Lecture Notes in Business Information Processing, vol 212. Springer, Cham. https://doi.org/10.1007/978-3-319-18612-2_1

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-18612-2_1

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-18611-5

  • Online ISBN: 978-3-319-18612-2

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics