Font Size: a A A

Identifying Refactoring Patterns Based On Code Clone Detection

Posted on:2020-01-07Degree:MasterType:Thesis
Country:ChinaCandidate:Z H ZhangFull Text:PDF
GTID:2428330575987985Subject:Computer application technology
Abstract/Summary:PDF Full Text Request
Code refactoring technology refers to the use of a series of refactoring techniques to improve and optimize the internal structure of the software,reduce its modification cost,increase its expandability,comprehensibility and maintainability while keeping the functionality of the software unchanged.It is a code adjustive technique at the structural level.Identifying refactoring patterns refers to comparing the pre-change original code and the post-change code to find a code segment that conforms to a certain refactoring mode.Code change often contains bug fixes,function additions,and refactoring change codes for the old version of the code.The combination of these different types of change codes increases the difficulty of reading the code and understand its contents.The automatic identifying refactoring change code can separate the refactoring code from other kinds of change behaviors,which facilitates the reading and understanding of the change code and helps the researchers understand the refactoring behavior in the code change.Researchers would learn from code modification and gain knowledge such as the way of refactoring,the motivation of refactoring,and the impact of refactoring on code quality,which is useful for understanding the evolution of software.Among several commonly used refactoring patterns,some of them include the operation of moved code lines in the process of refactoring.In the practice of refactoring,The moved code lines before and after refactoring don't come from copying.In many cases,you need to adjust the moved lines of code to a certain degree,such as adjusting the variable name,constant name,character case,modifier,curly braces,identifier,number,string,or part of the code that adds to post-codes or removes from pre-code.Since there are not so many researches on refactoring pattern identification at home or abroad,and there is no effective and accurate way to identify the refactoring patterns under this situation.In this paper,an identifying pattern method based on code-clone-detection is proposed.First,the code-clone-detection technology is used to filter the code change blocks(hunk)from the set of two adjacent versions of the source files obtained by the text-based code difference analysis tool.Because these hunk sets have covered all the differences in information,all the moving codes' behaviors occur in these differences.So using the code-clone-detection method to detect them will not miss or misjudge the above situation.and then we screen outthe hunks which may contain refactoring patterns,and then classify these hunks as candidate hunks,and make them the input of the next text-based or abstract syntax tree based syntax analysis method,and accurately determine whether there are refactoring patterns and if so what kind of refactoring patterns there are.In this paper,we've studied Extract Method,Inline Method and Extract Class which belong to the level of whole method;Rename Method,Add Parameter and Remove Parameter which belong to the level of method head,and Substitute Algorithm which belongs to the level of method body.Due to the different levels of refactoring behaviors,different complexity,and different structural characteristics,this paper presents different algorithm implementations based on code-clone-detection for each type of refactoring pattern,and for Rename Method,Add Parameter and Remove Parameter we use the text-based syntax analysis method to judge candidate hunk sets in the final step of the algorithm.For other more complex refactoring patterns,in this article we use the abstract syntax tree based method to judge candidate hunk sets.This paper has carried out experimental verification on the dataset from 4 open source projects,which shows that it has high accuracy.
Keywords/Search Tags:Refactoring pattern, Refactoring pattern identification, Code changes, Code clone detection
PDF Full Text Request
Related items