Open Access Open Access  Restricted Access Subscription or Fee Access

Omitting Code Clones Based on Ranking the Called Clones

Shahenda Sarhan(1*), Zyad Dhafer(2)

(1) Faculty of Computers and Information, Mansoura University, Egypt
(2) Faculty of Computers and Information, Mansoura University, Egypt
(*) Corresponding author



Code clones represent a stumbling blocking the way of having a more readable, maintainable and less complicated source codes, free of bugs and errors. Many studies had been proposed for detecting and omitting the four types of cloned codes based on pattern matching, syntax parsing, tree parsing and refactoring which is the most commonly used technique to remove the code clones from software, while maintaining its original behavior. In this paper, we propose an automated refactoring technique and its correspondence algorithm to omit code clones of type 1 and type 2. The proposed technique performance was tested and evaluated using four open source Java projects JFreeChart, JRuby, JCommon and Apache ant. The performance of the source codes was indicated based on number of metrics as the lines of code, number of blank lines, method’s count and cyclomatic complexity before and after applying the proposed technique. The experimentation results indicated that the proposed technique had showed superiority over the state-of-the-art through omitting the cloned codes with the possibility of maintaining the stability and correctness of behavior of the source codes under consideration.
Copyright © 2016 Praise Worthy Prize - All rights reserved.


Code Clones; Clone Refactoring; Abstract Syntax Tree; Damerau–Levenshtein Distance

Full Text:



M. Tufano, F. Palomba,, G. Bavota, R. Oliveto, M. Di Penta, A. De Lucia & D. Poshyvanyk, When and why your code starts to smell bad, (2015, May), In Proceedings of the 37th International Conference on Software Engineering,(1), pp. 403-414, ISBN: 978-1-4799-1934-5, IEEE Press. ‏

C. K. Roy, & J. R. Cordy, A survey on software clone detection research‏,(2007), Technical Report 541, Queen’s University at Kingston.
Avaliable in http://maveric0. uwaterloo. ca/~migod/846/papers/roy-CloningSurveyTechReport. pdf

S. Shafieian, & Y. Zou, Comparison of Clone Detection Techniques,(2012)‏, Technical report Queen’s University, Kingston, Canada.
Avaliable in https://www.

J. Li & M. D. Ernst, CBCD: Cloned Buggy Code Detector,(2012, June), In Proceedings of the 34th International Conference on Software Engineering, pp. 310-320, ISBN: 978-1-4673-1067-3, IEEE Press. ‏

H. Kim, Y. Jung, S. Kim & K. Yi MeCC: Memory Comparison-Based Clone Detector, (2011, May). In Proceedings of 33rd International Conference on Software Engineering (ICSE), pp. 301-310.

E. Murphy-Hill, C. Parnin & A. P. Black, How we refactor, and how we know it(2012), IEEE Transactions on Software Engineering, 38(1), pp. 5-18.

I. G. de Guzmán, M. Piattini & R. Pérez-Castillo, Green software maintenance, ‏(2015), In Green in Software Engineering,Springer International Publishing, pp. 205-229.

A. Hessellund, Refactoring as a Technique for the Reengineering of Legacy Systems, (2004), ITU, København.
Avaliable in https://www.

M. Fowler, Refactoring: Improving The Design Of Existing Code,(Pearson Education India,2009).
Avaliable in http://esigatesting. inta. gov. ar/webdav/files/pdf/sample-signed. pdf

M. F. Zibran & C. K. Roy, Conflict-aware optimal scheduling of prioritised code clone refactoring, (2013), Software, IET, 7(3), pp. 167-186.

M. F. Zibran & C. K. Roy, Towards flexible code clone detection, management, and refactoring in IDE, (2011), Proceedings of the 5th International Workshop on Software Clones, pp. 75-76.

R. Tairas & J. Gray, Increasing Clone Maintenance Support By Unifying Clone Detection And Refactoring Activities, (2012), Information and Software Technology, 54(12), pp. 1297 -1307.

M. Kim, T. Zimmermann & N. Nagappan, A Field Study Of Refactoring Challenges And Benefits, (2012, November), In Proceedings of the ACM SIGSOFT 20th International Symposium on the Foundations of Software Engineering, pp. 50, ISBN: 978-1-4503-1614-9.

E. Choi, N. Yoshida & K. Inoue, What Kind Of And How Clones Are Refactored?: A Case Study Of Three OSS Projects, (2012), In Proceedings of the Fifth Workshop on Refactoring Tools, pp. 1-7, ISBN: 978-1-4503-1500-5.

X. Ge & E. Murphy-Hill, Manual Refactoring Changes With Automated Refactoring Validation, (2014, May), In Proceedings of the 36th International Conference on Software Engineering, pp. 1095-1105., ISBN: 978-1-4503-2756-5.

G. Szőke, C. Nagy, R. Ferenc & T. Gyimóthy, A Case Study Of Refactoring Large-Scale Industrial Systems To Efficiently Improve Source Code Quality,(2014), Computational Science and Its Applications–ICCSA 2014, pp. 524-540.

G. P. Krishnan & N. Tsantalis, Unification And Refactoring Of Clones, (2014, February), In Proceedings ofWeek-IEEE Conference onSoftware Maintenance, Reengineering and Reverse Engineering (CSMR-WCRE), 2014 Software Evolution, pp. 104-113, Electronic ISBN: 978-1-4799-3752-3.

H. A. Basit, H. S. Khan, F. Hamid & I. Suhail, Tool Support For Managing Method Clones, (2015), IEEE 9th International Workshop on Software Clones (IWSC), pp. 40 -46, ElectronicISBN: 978-1-4673-6914-5.

M. Mondal,, C. K. Roy & K. A. Schneider, SPCP-Miner: A Tool For Mining Code Clones That Are Important For Refactoring Or Tracking, (2015, March), In 2015 IEEE 22nd International Conference on Software Analysis, Evolution and Reengineering (SANER), pp. 484-488, Electronic ISBN: 978-1-4799-8469-5.

N. Tsantalis, D. Mazinanian & G. P. Krishnan, Assessing the Refactorability of Software Clones, (2015), IEEE Transactions on Software Engineering,41(11), pp. 1055 -1090.

E. L. Alves, T. Massoni & P. D. de Lima Machado, Test Coverage Of Impacted Code Elements For Detecting Refactoring Faults: An Exploratory Study,(2016), Journal of Systems and Software. ‏ ISSN 0164-1212.

D. Saha, P. Dhoolia, M. Garg & V. Vaibhav, Delta Refactoring for Merge Conflict Avoidance, (2016, February), In Proceedings of the 9th India Software Engineering Conference, pp. 26-36.

J. Xuan, B. Cornu,, M. Martinez, B. Baudry, L. Seinturier & M. Monperrus, B-Refactoring: Automatic Test Code Refactoring To Improve Dynamic Analysis, (2016). Information and Software Technology, (76), pp. 65-80.

B. Biegel & S. Diehl, Highly configurable and extensible code clone detection, (2010, October), In 17th Working Conference onReverse Engineering (WCRE), pp. 237-241, Print ISSN: 1095-1350.

I. D. Baxter, A. Yahin, L. Moura, M. S. Anna & L. Bier,. Clone Detection Using Abstract Syntax Trees,(16-20 Nov 1998), In Proceedings of International Conference on Software Maintenance, pp. 368-377, PrintISSN: 1063-6773.

F. J. Damerau, A Technique For Computer Detection And Correction Of Spelling Errors, (1964), Communications of the ACM, 7(3), pp. 171-176. ‏

V. I. Levenshtein, Binary codes capable of correcting deletions, insertions, and reversals, (1966, February), In Soviet physics doklady, 10(8), pp. 707-710. ‏

Damerau–Levenshtein distance, available at: https://en. wikipedia. org/wiki/Damerau%E2%80%93Levenshtein_distance [accessed at: 23/12/2015]

JavaParser version 1. 5, available at: https://code. google. com/archive/p/javaparser/ [accessed at: 12/12/2015]

A. H. Watson, T. J. McCabe & D. R. Wallace, Structured testing: A testing methodology using the cyclomatic complexity metric, (1996), NIST special Publication, 500(235), 1-114.
Available in http://asetechs. com/NewSite2015/Documentation/_ressources/QualityMeasurements/McCabe_cyclomatic_audit_process. pdf

JFree, available at: http://www. jfree. org/jfreechart/ [accessed at : 25/1/2016]

JRuby, avalable at: http://jruby. org/ [accessed at : 29/1/2016]

JCommon, available in: http://www. java2s. com/Code/Jar/j/Downloadjcommonjar. htm [accessed at : 29/1/2016]

The Apache Ant, available in: https://ant. apache. org/bindownload. cgi [accessed at : 15/2/2016]


  • There are currently no refbacks.

Please send any question about this web site to
Copyright © 2005-2022 Praise Worthy Prize