Abstract
Eliminating code clones is good for improving the quality and maintainability of software. Structure semantics similar code clones are more difficult to be refactored than other types of clones. This paper presents an algorithm for refactoring structure semantics similar clones. Structure semantics similar clones are the clones that have similar program dependence graph (PDGs) after semantic equivalent standardization transformation. The graph-based standardization method can identify the semantically similar code clones effectively with a high computation complexity. The metrics-based method has a lower computation complexity but also has a lower accuracy of identification. To solve this problem, this paper first uses the metrics-based method to filter out most candidate clones not suitable for refactoring and then further confirms the structure semantics similar clones that are suitable for refactoring by code standardization, PDGs matching, and similarity comparison. Structure semantics we propose a new approach for refactoring structure semantics similar clones combining standardization with metrics. The experiments results in open source codes show that this method behaves well in refactoring structure semantics similar clones.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
References
Kamiya, T., Kusumoto, S., Inoue, K.: CCFinder: a multilinguistic token-based code clone detection system for large scale source code. IEEE Trans. Softw. Eng. 28(7), 654–670 (2002)
Roy, C.K., Cordy, J.R., Koschke, R.: Comparison and evaluation of code clone detection techniques and tools: a qualitative approach. Sci. Comput. Program. 74, 470–495 (2009)
Wang, Q.: C Code Clone and Related Software Defect Detection Based on Sequence Mining, pp. 1–47. Harbin Institute of Technology Computer Science and Technology School, Harbin (2009)
Chou, A., Yang, J., Chelf, B., Hallem, S., Engler, D.: An empirical study of operating systems errors. In: Proceedings of the Eighteenth ACM Symposium on Operating systems principles, SOSP’01, pp. 73–88 (2001)
Fowler, M.: Refactoring: Improving the Design of Existing Code. Addison Wesley, Reading (1999)
Wang, T.: The study to identify structure semantics similar programs. Doctoral Dissertation, Harbin Institute of Technology (2009)
Baker, B.S.: On finding duplication and near-duplication in large software systems. In: Working Conference on Reverse Engineering (WCRE), pp. 86–95 (1995)
Baxter, D., Yahin, A., Moura, L., Sant’Anna, M., Bier, L.: Clone detection using abstract syntax trees. In: ICSM, pp. 368–377 (1998)
Jiang, L., Misherghi, G., Su, Z., Glondu, S.: Deckard: scalable and accurate tree-based detection of code clones. In: ICSE, pp. 96–105 (2007)
Kamiya, T., Kusumoto, S., Inoue, K.: CCFinder: a multilinguistic token-based code clone detection system for large scale source code. TSE 28(7), 654–670 (2002)
Kim, H., Jung, Y., Kim, S., Yi, K.: MeCC: memory comparison-based clone detector. In: 33rd International Conference on Software Engineering, ACM, pp. 301–310 (2011)
Jiang, L.: Scalable detection of similar code. Techniques and Applications. Computer 82–119 (2009)
Jiang, L., Su, Z.: Automatic mining of functionally equivalent code fragments via random testing. In: ISSTA ‘09 Proceedings of the Eighteenth International Symposium on Software Testing and Analysis, pp. 81–91 (2009)
Kong, D., Su, X., Wu, S., et al.: Detect functionally equivalent code fragments via K-nearest neighbor algorithm. IEEE 5th International Conference on Advanced Computational Intelligence(ICACI), Oct. 18(20), pp. 94–98. Nanjing, Jiangsu, China (2012)
Balazinska, M., Merlo, E., Dagenais, M., et al.: Advanced clone-analysis to support object-oriented system refactoring In: Proceedings. Seventh Working Conference on Reverse Engineering, pp. 98–107. IEEE (2000)
Higo, Y., Kusumoto, S., Inoue, K.: A metric-based approach to identifying refactoring opportunities for merging code clones in a Java software system. J. Softw. Maintenance Evol. Res. Pract. 20(6), 435–461 (2008)
Schulze, S., Kuhlemann, M., Rosenmüller, M.: Towards a refactoring guideline using code clone classification. In: Proceedings of the 2nd Workshop on Refactoring Tools. ACM, p. 6 (2008)
Feng, J.: Code clone restructuring of c programs via K-nearest neighbor algorithm. Harbin Institute of TechnologyComputer Science and Technology School, Harbin, pp. 1–57 (2011)
Yu, D., Peng, X., Zhao, W.: Automatic refactoring method of cloned code using abstract syntax tree and static analysis. J. Chin. Comput. Syst. 30(9), 1752–1760 (2009)
Acknowledgments
This research is supported by the National Natural Science Foundation of China (Grant No. 61173021) and the Research Fund for the Doctoral Program of Higher Education of China (Grant Nos. 20112302120052 and 20092302110040).
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2014 Springer India
About this paper
Cite this paper
Li, X., Su, X., Ma, P., Wang, T. (2014). Refactoring Structure Semantics Similar Clones Combining Standardization with Metrics. In: Patnaik, S., Li, X. (eds) Proceedings of International Conference on Soft Computing Techniques and Engineering Application. Advances in Intelligent Systems and Computing, vol 250. Springer, New Delhi. https://doi.org/10.1007/978-81-322-1695-7_41
Download citation
DOI: https://doi.org/10.1007/978-81-322-1695-7_41
Published:
Publisher Name: Springer, New Delhi
Print ISBN: 978-81-322-1694-0
Online ISBN: 978-81-322-1695-7
eBook Packages: EngineeringEngineering (R0)