arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2212.12195cs.SE
收藏

RMove:使用代码的结构和语义表示推荐Move方法重构机会

RMove: Recommending Move Method Refactoring Opportunities using Structural and Semantic Representations of Code

Di Cui, Siqi Wang, Yong Luo, Xingyu Li, Jie Dai, Lu Wang, Qingshan Li

摘要:

方法在类中的不正确放置是一种典型的代码气味,称为特性嫉妒,这会在演化过程中导致额外的维护和成本。为了消除这个设计缺陷,已经提出了几个MoveMethod重构工具。据我们所知,最先进的相关技术可以大致分为两类:第一类是基于软件度量的非机器学习方法,而软件度量的选择和阈值严重依赖于专家知识。第二行是基于机器学习的方法,它建议通过学习从代码信息中提取特征来重构Move Method。然而,这一行中的大多数方法都以相同的方式处理不同形式的代码信息,而忽略了它们在数据分析中的显著差异。本文提出了一种推荐Move方法重构的方法RMove,该方法通过自动学习代码片段的结构和语义表示来推荐Move方法重构。我们将这些表示连接在一起,并进一步训练机器学习分类器,以引导方法移动到合适的类。我们在两个公开的数据集上评估了我们的方法。结果表明,我们的方法优于三个国家的最先进的重构工具,包括PathMove,JDeodorant和JMove的有效性和实用性。研究结果还揭示了有用的发现,并提供了新的见解,有利于其他类型的功能羡慕重构技术。

英文摘要:

Incorrect placement of methods within classes is a typical code smell called Feature Envy, which causes additional maintenance and cost during evolution. To remove this design flaw, several Move Method refactoring tools have been proposed. To the best of our knowledge, state-of-the-art related techniques can be broadly divided into two categories: the first line is non-machine-learning-based approaches built on software measurement, while the selection and thresholds of software metrics heavily rely on expert knowledge. The second line is machine learning-based approaches, which suggest Move Method refactoring by learning to extract features from code information. However, most approaches in this line treat different forms of code information identically, disregarding their significant variation on data analysis. In this paper, we propose an approach to recommend Move Method refactoring named RMove by automatically learning structural and semantic representation from code fragment respectively. We concatenate these representations together and further train the machine learning classifiers to guide the movement of method to suitable classes. We evaluate our approach on two publicly available datasets. The results show that our approach outperforms three state-of-the-art refactoring tools including PathMove, JDeodorant, and JMove in effectiveness and usefulness. The results also unveil useful findings and provide new insights that benefit other types of feature envy refactoring techniques.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑