计算机应用 ›› 2018, Vol. 38 ›› Issue (7): 2037-2043.DOI: 10.11772/j.issn.1001-9081.2017122997

• 计算机软件技术 • 上一篇    下一篇

基于决策树推荐克隆重构的方法

折蓉蓉, 张丽萍, 侯敏, 闫盛   

  1. 内蒙古师范大学 计算机与信息工程学院, 呼和浩特 010022
  • 收稿日期:2017-12-21 修回日期:2018-02-07 出版日期:2018-07-10 发布日期:2018-07-12
  • 通讯作者: 张丽萍
  • 作者简介:折蓉蓉(1991-),女,内蒙古鄂尔多斯人,硕士研究生,主要研究方向:软件工程、软件分析;张丽萍(1974-),女,内蒙古呼和浩特人,教授,硕士,CCF会员,主要研究方向:软件工程、软件分析;侯敏(1972-),女,内蒙古呼和浩特人,讲师,硕士,主要研究方向:软件分析、计算机辅助教学;闫盛(1984-),男,内蒙古包头人,讲师,硕士,主要研究方向:软件分析、并行计算。
  • 基金资助:
    国家自然科学基金资助项目(61462071);内蒙古自然科学基金资助项目(2016MS0612)。

Recommending clone refactoring method based on decision tree

SHE Rongrong, ZHANG Liping, HOU Min, YAN Sheng   

  1. College of Computer and Information Engineering, Inner Mongolia Normal University, Hohhot Nei Mongol 010022, China
  • Received:2017-12-21 Revised:2018-02-07 Online:2018-07-10 Published:2018-07-12
  • Supported by:
    This work is partially supported by the National Natural Science Foundation of China (61462071), the Natural Science Foundation of Inner Mongolia Autonomous Region (2016MS0612).

摘要: 针对克隆代码的大量使用会导致长期软件维护问题甚至引入错误,提出了一种基于决策树的分类器来推荐克隆进行重构。首先,使用NiCad进行克隆检测;其次,收集了与克隆关系、克隆代码段和克隆上下文都相关的特征;然后,利用决策树分类器训练;最后,利用K折交叉评估分类结果。在5款开源软件中对近600多个克隆实例进行实验,实验结果表明所提方法为每个目标系统推荐克隆重构实例时达到80%的精度。

关键词: 克隆代码, 克隆重构, 克隆检测, 决策树, 特征选择

Abstract: Aiming at long-term software maintenance even introduction of errors due to extensive use of cloned code, a classifier based on decision tree was proposed to recommend clone for refactoring. Firstly, clone detection was performed using NiCad. Secondly, the features related to cloning relationship, cloned code segment and clonal context were collected. Thirdly, a decision tree classifier was used for training. Finally, the classification results were evaluated by K-fold crossover. The experiments were conducted on nearly 600 clones in five kinds of open-source software. The experimental results show that the proposed method achieves 80% accuracy when recommending clonal refactoring instances for each target system.

Key words: code clone, clone refactoring, clone detection, decision tree, feature selection

中图分类号: