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.
翻译:类中方法的不正确位置是一种典型的代码气味,叫做“功能性恩维”,它导致进化过程中额外的维护和成本。然而,为了消除这一设计缺陷,提出了若干移动方法的重新构思工具。根据我们的最佳知识,最先进的相关技术可以大致分为两类:第一行是基于软件测量的非机械学习方法,而软件指标的选择和阈值则严重依赖专家知识。第二行是机器学习方法,它建议通过学习从代码信息中提取特征来重新构思移动方法。然而,这一行的大多数方法以相同的方式处理不同形式的代码信息,而无视数据分析方面的显著差异。我们在此文件中建议一种方法,通过自动学习代码碎片的结构和语义表达方式来重新构思名为RMove。我们将这些表达方式组合在一起,并进一步培训机器学习分类师,以指导方法向合适的班级的移动。我们评估了两个公开可用的数据集中我们的方法。结果显示,我们的方法超越了三种州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州-州