Refactoring Support Based on Code Clone Analysis

  • Yoshiki Higo
  • Toshihiro Kamiya
  • Shinji Kusumoto
  • Katsuro Inoue
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3009)


Software maintenance is the most expensive activity in software development. Many software companies spent a large amount of cost to maintain the existing software systems. In perfective maintenance, refactoring has often been applied to the software to improve the understandability and complexity. One of the targets of refactoring is code clone. A code clone is a code fragment in a source code that is identical or similar to another. In an actual software development process, code clones are introduced because of various reasons such as reusing code by ‘copy-and-paste’ and so on. Code clones are one of the factors that make software maintenance difficult. In this paper, we propose a method which removes code clones from object oriented software by using existing refactoring patterns, especially “Extract Method” and “Pull Up Method”. Then, we have implemented a refactoring supporting tool based on the proposed method. Finally, we have applied the tool to an open source program and actually perform refactoring.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    ANTLR (2000),
  2. 2.
    Baker, B.S.: Parameterized Duplication in Strings: Algorithms and an Application to Software Maintenance. SIAM Journal on Computing 26(5), 1343–1362 (1997)zbMATHCrossRefMathSciNetGoogle Scholar
  3. 3.
    Baxter, D., Yahin, A., Moura, L., Sant’Anna, M., Bier, L.: Clone Detection Using Abstract Syntax Trees. In: Proc. of ICSM 1998, pp. 368–377 (1998)Google Scholar
  4. 4.
    Balazinska, M., Merlo, E., Dagenais, M., Lagu, B., Kontogiannis, K.: Measuring clone based reengineering opportunities. In: Proc. of METRICS 1999, pp. 292–303 (1999)Google Scholar
  5. 5.
    Balazinska, M., Merlo, E., Dagenais, M., Lagu, B., Kontogiannis, K.: Advanced Clone-Analysis to Support Object-Oriented System Refactoring. In: Proc. of WCRE 2000, pp. 98–107 (2000)Google Scholar
  6. 6.
    Ducasse, S., Rieger, M., Demeyer, S.: A Language Independent Approach for Detecting Duplicated Code. In: Proc. of ICSM 1999, pp. 109–118 (1999)Google Scholar
  7. 7.
    Fowler, M.: Refactoring: improving the design of existing code. Addison Wesley, Reading (1999)Google Scholar
  8. 8.
    Mayland, J., Leblanc, C., Merlo, E.: Experiment on the Automatic Detection of Function Clones in a Software System Using Metrics. In: Proc. of ICSE 1996, pp. 244–253 (1996)Google Scholar
  9. 9.
    IEEE Std 1219-1992: Standard for Software Maintenance (1992)Google Scholar
  10. 10.
    Kamiya, T., Kusumoto, S., Inoue, K.: CCFinder: A multi-linguistic token-based code clone detection system for large scale source code. IEEE Trans. on Software Engineering 28(7), 654–670 (2002)CrossRefGoogle Scholar
  11. 11.
    Kataoka, Y., Imai, T., Andou, H., Fukaya, T.: A quantitative evaluation of maintainability enhancement by refactoring. In: Proc. of ICSM 2002, pp. 576–585 (2002)Google Scholar
  12. 12.
    Komondoor, R., Horwitz, S.: Using slicing to identify duplication in source code. In: Proc. of the 8th International Symposium on Static Analysis, pp. 40–56 (2001)Google Scholar
  13. 13.
    Kontogiannis, K., DeMori, R., Merlo, E., Galler, M., Bernstein, M.: Pattern Matching Techniques for Clone Detection. Journal of Automated Software Engineering 3, 77–108 (1996)CrossRefMathSciNetGoogle Scholar
  14. 14.
    Krinke, J.: Identifying Similar Code with Program Dependence Graphs. In: Proc. of the 8th Working Conference on Reverse Engineering, pp. 562–584 (2001)Google Scholar
  15. 15.
    Higo, Y., Ueda, Y., Kamiya, T., Kusumoto, S., Inoue, K.: On software maintenance process improvement based on code clone analysis. In: Oivo, M., Komi-Sirviö, S. (eds.) PROFES 2002. LNCS, vol. 2559, pp. 185–197. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  16. 16.
    Ueda, Y., Kamiya, T., Kusumoto, S., Inoue, K.: Gemini: Maintenance Support Environment Based on Code Clone Analysis. In: 8th International Symposium on Software Metrics, June 4-7 (2002)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2004

Authors and Affiliations

  • Yoshiki Higo
    • 1
  • Toshihiro Kamiya
    • 2
  • Shinji Kusumoto
    • 1
  • Katsuro Inoue
    • 1
  1. 1.Graduate School of Information Science and TechnologyOsaka UniversityToyonakaJapan
  2. 2.PRESTO, Japan Science and Technology Agency Current Address: Graduate School of Information Science and TechnologyOsaka UniversityToyonakaJapan

Personalised recommendations