论文标题
探索用于提取类重构建议的变异图自动编码器
Exploring Variational Graph Auto-Encoders for Extract Class Refactoring Recommendation
论文作者
论文摘要
代码气味是软件系统中设计和开发缺陷的标志,可降低系统的可重复性和可维护性。重构是作为一种持续的做法来消除程序代码中的代码气味。在不同的代码气味中,上帝的阶级或斑点是最常见的代码气味之一。上帝的阶级包含太多责任,违反了面向对象的编程设计的低耦合和高凝聚力原则。本文提出了一种自动方法,将上帝的班级提取为具有更具体责任的多个较小的班级。为此,我们首先构建了有关上帝阶级的方法(作为节点)的图表。任意两种方法之间的边缘由它们的结构相似性确定,并且使用不同的语义表示方法初始化了每种方法的特征。然后,变分图自动编码器用于学习每种方法的向量表示。最后,学习的向量用于将方法聚集到不同的组中,以推荐作为重构类。我们使用三个不同的类凝聚力指标评估了提出的框架,这些指标是从两个众所周知的开源系统收集的十六个实际的上帝班级。我们还使用类似的现有方法对我们的方法进行了比较研究,发现所提出的方法几乎为实验中使用的所有上帝类带来了更好的结果。
The code smell is a sign of design and development flaws in a software system that reduces the reusability and maintainability of the system. Refactoring is done as an ongoing practice to remove the code smell from the program code. Among different code smells, the God class or Blob is one of the most common code smells. A god class contains too many responsibilities, violating object-oriented programming design's low coupling and high cohesiveness principles. This paper proposes an automatic approach to extracting a God class into multiple smaller classes with more specific responsibilities. To do this, we first construct a graph of methods (as nodes) for the concerning god class. The edge between any two methods is determined by their structural similarity, and the feature for each method is initialized using different semantic representation methods. Then, the variational graph auto-encoder is used to learn a vector representation for each method. Finally, the learned vectors are used to cluster methods into different groups to be recommended as refactored classes. We assessed the proposed framework using three different class cohesion metrics on sixteen actual God Classes collected from two well-known open-source systems. We also conducted a comparative study of our approach with a similar existing approach and found that the proposed approach generated better results for almost all the God Classes used in the experiment.