Code smell is a great challenge in software refactoring, which indicates latent design or implementation flaws that may degrade the software maintainability and evolution. Over the past decades, a variety of refactoring approaches have been proposed, which can be broadly classified into metrics-based, rule-based, and machine learning-based approaches. Recent years, deep learning-based approaches have also attracted widespread attention. However, existing techniques exhibit various limitations. Metrics- and rule-based approaches rely heavily on manually defined heuristics and thresholds, whereas deep learning-based approaches are often constrained by dataset availability and model design. In this study, we proposed a graph-based deep learning approach for code smell refactoring. Specifically, we designed two types of input graphs (class-level and method-level) and employed both graph classification and node classification tasks to address the refactoring of three representative code smells: long method, large class, and feature envy. In our experiment, we propose a semi-automated dataset generation approach that could generate a large-scale dataset with minimal manual effort. We implemented the proposed approach with three classical GNN (graph neural network) architectures: GCN, GraphSAGE, and GAT, and evaluated its performance against both traditional and state-of-the-art deep learning approaches. The results demonstrate that proposed approach achieves superior refactoring performance.


翻译:代码异味是软件重构中的重大挑战,它指示了可能降低软件可维护性和可演化性的潜在设计或实现缺陷。过去几十年间,研究者提出了多种重构方法,可大致分为基于度量、基于规则和基于机器学习的方法。近年来,基于深度学习的方法也引起了广泛关注。然而,现有技术存在各种局限性:基于度量和规则的方法严重依赖人工定义的启发式规则和阈值,而基于深度学习的方法则常受限于数据集可用性和模型设计。在本研究中,我们提出了一种基于图的深度学习方法用于代码异味重构。具体而言,我们设计了两种类型的输入图(类级和方法级),并采用图分类和节点分类两种任务来处理三种代表性代码异味(长方法、大类、特征依恋)的重构。实验中,我们提出了一种半自动数据集生成方法,能够以最少的手动工作量生成大规模数据集。我们使用三种经典图神经网络架构(GCN、GraphSAGE和GAT)实现了所提出的方法,并与传统及最先进的深度学习方法进行了性能对比。结果表明,所提出的方法实现了更优的重构性能。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
《基于动态图神经网络的恶意软件检测》
专知会员服务
16+阅读 · 1月28日
基于深度学习的图异常检测技术综述
专知会员服务
87+阅读 · 2021年7月28日
深度学习赋能的恶意代码攻防研究进展
专知会员服务
31+阅读 · 2021年4月11日
【Code】GraphSAGE 源码解析
AINLP
31+阅读 · 2020年6月22日
【GNN】深度学习之上,图神经网络(GNN )崛起
产业智能官
16+阅读 · 2019年8月15日
使用 Canal 实现数据异构
性能与架构
20+阅读 · 2019年3月4日
国家自然科学基金
2+阅读 · 2016年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
VIP会员
最新内容
俄罗斯如何拦截乌克兰无人机与巡航导弹
专知会员服务
8+阅读 · 10月15日
《武器-目标分配问题:精确与近似求解算法》
专知会员服务
11+阅读 · 10月15日
综述|谁来改进机器人?迈向物理递归自我改进
专知会员服务
10+阅读 · 10月14日
软件定义无人机蜂群给防空带来全新压力
专知会员服务
10+阅读 · 10月13日
《半自主无人地面战车的互操作性》66页
专知会员服务
14+阅读 · 10月13日
相关基金
国家自然科学基金
2+阅读 · 2016年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
Top
微信扫码咨询专知VIP会员