Font Size: a A A

Research On Refactoring Analysis Of Software Clone Code

Posted on:2019-03-22Degree:MasterType:Thesis
Country:ChinaCandidate:Y T YaoFull Text:PDF
GTID:2348330566459849Subject:Software engineering
Abstract/Summary:PDF Full Text Request
During development of software,in order to reduce the cost of software development,developers always copy and past code,which result in that there occures some alike or similar code in the software.The reusable code is called clone code.The existing research suggests that clone code is potentially harmful to the maintainability and evolution of software.However,the research results about eliminating clone code through refactoring are still limited,because the refactoring of clone code is a very challenging issue.In particular,after the initial introduction of clone code,the refactoring will be more complicated after multiple modifications.Judging from the purpose of the study,finding a way to evaluate whether clone code can be refactored without changing the behavior of the program is the key to this research.The clone code with a nested structure is a relatively representative compared with other types of clone and refactoring this type of clone code can quickly eliminate the redundant code of the software,this paper takes the clone code with a nested structure as an object of the study.The study is implemented in the following four steps:clone code detection,clone code nested structure matching,clone code mapping,and the setting about clone code preconditions of refactoring.The specific work is as follows:1.The research get clone code from four detection tools: Ni Cad,CCFinder,Deckard and CloneDR.Firstly,the source code is constructed as an abstract syntax tree using the AST construction algorithm;second,using the recursive function to return the optimal subtree matching algorithm to select the clone code with the same nested structure;then,the neste structural subtrees with the same nested structure are mapped by the optimal mapping algorithm.Finally,the tree mapping algorithm based on depth first is used to combine the subtree mappings to form a global mapping solution.2.When the mapping is completed,it is necessary to determine whether the two clone code fragments can be safely refactored by parameterizing the difference between mapping statements.In this study,six clone refactoring preconditions were set from three perspectives of extraction method,mapping statement differences and unmapped statements to judge the refactoring of clone code.If the clone code violates any of the preconditions,then it is not suitable for refactoring,or refactoring it may cause the behavior of the source program to change.3.Based on the above research methods,this study aimed at 9 open source software for clone code refactory recognition,and compared with the current popular refactoring tool Ce DAR,this method identifies 4 times more refactorable clones than CeDAR,refactorable rate raise from 20% to 37%.In addition,this paper evaluates the experimental method from three aspects: refactorable scale,time performance,and performance of optimal mapping algorithm.The final result shows that the refactored rate of the clone code recommended by this method is 90%,and the time cost is small.It proves that this study is feasible and effective.
Keywords/Search Tags:clone code, refactoring, optimal mapping algorithm, software maintenance
PDF Full Text Request
Related items