期刊文献+

基于类关联关系的源代码重构时机识别

Identification of refactoring opportunities for source code based on class association relationships
下载PDF
导出
摘要 针对面向对象软件系统中类与类之间存在的复杂关联关系,提出了一种基于类关联关系的代码重构时机识别方法,可用于探测代码中存在的重复多对多关联关系,为进一步实施重构提供指导。该方法首先将源代码转换成抽象语法树,然后提取每一个类的成员变量,得到每一个类的关联类集,再寻找类之间的公共关联类,最后根据设定的阈值,保存并输出满足预定条件的候选重构类集以及它们的公共关联类。通过对四个项目进行重构时机识别实验,结果表明,当阈值为3时,方法的精确率超过96%,当阈值为4时精确率达到100%。同时,方法具有较好的执行效率,对于超过500个类的项目,识别程序的执行时间不到4 s,说明该方法可有效应用于不同规模项目的重构时机识别。 In order to deal with the complex association relationships between classes in an object-oriented software system,a novel approach for identifying refactoring opportunities is proposed.The approach can be used to detect complex and duplicated many-to-many association relationships in source code,and to provide guidance for further refactoring.In the approach,source code is first transformed to an abstract syntax tree from which all data members of each class are extracted,then each class is characterized in connection with a set of association classes saving its data members.Next,classes in common associations are obtained by comparing different association classes sets in integrated analysis.Finally,on condition of pre-defined thresholds,all class sets in candidate for refactoring and their common association classes are saved and exported.This approach is tested on 4 projects.The results show that the precision is over 96%when the threshold is 3,and 100%when the threshold is 4.Meanwhile,this approach has good execution efficiency as the execution time taken for a project with more than 500 classes is less than 4 s,which also indicates that it can be applied to projects of different scales to identify their refactoring opportunities effectively.
作者 刘伟 杨娜 黄辛迪 胡为 胡志刚 LIU Wei;YANG Na;HUANG Xin-di;HU Wei;HU Zhi-gang(School of Informatics,Hunan University of Chinese Medicine,Changsha 410208,China;School of Computer Science and Engineering,Central South University,Changsha 410083,China)
出处 《Journal of Central South University》 SCIE EI CAS CSCD 2020年第12期3768-3778,共11页 中南大学学报(英文版)
关键词 重构时机识别 抽象语法树 类关联关系 公共关联类 源代码 identification of refactoring opportunities abstract syntax tree class association relationships common association classes source code
  • 相关文献

相关作者

内容加载中请稍等...

相关机构

内容加载中请稍等...

相关主题

内容加载中请稍等...

浏览历史

内容加载中请稍等...
;
使用帮助 返回顶部