paperbot · PL 论文追踪

全部论文 待读 收藏

P2 One-to-One or One-to-Many? Suggesting Extract Class Refactoring Opportunities with Intra-class Dependency Hypergraph Neural Network

一对一还是一对多?基于类内依赖超图神经网络建议 Extract Class 重构机会
ISSTA Proceedings of the 33rd ACM SIGSOFT International Symposium on Software Testing and Analysis2024匹配度 3/10 · 论文聚焦于用超图神经网络和LLM推荐Extract Class重构机会,属于机器学习辅助软件重构,而非用户核心关注的静态分析、形式化验证、浮点程序分析或贝叶斯程序分析。虽然标签含程序分析与机器学习交叉,但任务目标与用户研究画像的匹配度较低。引用 4 inbox
Di Cui, Qiangqiang Wang, Yutong Zhao, Jiaqi Wang, Minjie Wei, Jingzhao Hu, Luqiao Wang, Qingshan Li
crossref: 2026-09-12

AI 速览

一句话:提出 HECS,用类内依赖超图神经网络与 LLM 建模一对多依赖,推荐 Extract Class 重构机会。

过大的类常承担多重职责,难以理解和维护。现有 Extract Class 重构工具多构建类内依赖图并依据硬编码规则发现机会,但图主要刻画实体间直接的一对一关系,忽略现实中普遍存在的一对多依赖,使建议可能偏离开发者需求。本文提出 HECS:为每个目标类构建类内依赖超图,用预训练代码模型为节点赋属性,输入增强超图神经网络训练,并结合大语言模型构建重构建议系统。作者在大规模数据集上训练,并在两个真实数据集上评估。相比 JDeodorant、SSECS 和 LLMRefactor,精确率提升 38.5%、召回率提升 9.7%、F1 提升 44.4%,对 64% 的参与者更有用,并给出对现有 Extract Class 技术的实践启示。

问题
现有基于类内依赖图的 Extract Class 重构工具只关注一对一依赖,难以捕捉现实类中一对多的复杂依赖,导致建议与开发者需求不符。
方法
构建类内依赖超图,以预训练代码模型赋节点属性,训练增强超图神经网络,并联合 LLM 构建重构建议系统。
评估
在大规模数据集训练,两个真实数据集评估,与 JDeodorant、SSECS、LLMRefactor 对比,并用 64% 参与者认可度及指标提升验证有效性。
原文摘要(Abstract)

Excessively large classes that encapsulate multiple responsibilities are challenging to comprehend and maintain. Addressing this issue, several Extract Class refactoring tools have been proposed, employing a two-phase process: identifying suitable fields or methods for extraction, and implementing the mechanics of refactoring. These tools traditionally generate an intra-class dependency graph to analyze the class structure, applying hard-coded rules based on this graph to unearth refactoring opportunities. Yet, the graph-based approach predominantly illuminates direct, “one-to-one” relationship between pairwise entities. Such a perspective is restrictive as it overlooks the complex, “one-to-many” dependencies among multiple entities that are prevalent in real-world classes. This narrow focus can lead to refactoring suggestions that may diverge from developers’ actual needs, given their multifaceted nature. To bridge this gap, our paper leverages the concept of intra-class dependency hypergraph to model one-to-many dependency relationship and proposes a hypergraph learning-based approach to suggest Extract Class refactoring opportunities named HECS. For each target class, we first construct its intra-class dependency hypergraph and assign attributes to nodes with a pre-trained code model. All the attributed hypergraphs are fed into an enhanced hypergraph neural network for training. Utilizing this trained neural network alongside a large language model (LLM), we construct a refactoring suggestion system. We trained HECS on a large-scale dataset and evaluated it on two real-world datasets. The results show that demonstrates an increase of 38.5% in precision, 9.7% in recall, and 44.4% in f1-measure compared to 3 state-of-the-art refactoring tools including JDeodorant, SSECS, and LLMRefactor, which is more useful for 64% of participants. The results also unveil practical suggestions and new insights that benefit existing extract-related refactoring techniques.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot8564,
  title = {One-to-One or One-to-Many? Suggesting Extract Class Refactoring Opportunities with Intra-class Dependency Hypergraph Neural Network},
  author = {Di Cui and Qiangqiang Wang and Yutong Zhao and Jiaqi Wang and Minjie Wei and Jingzhao Hu and Luqiao Wang and Qingshan Li},
  booktitle = {ISSTA},
  year = {2024},
  doi = {10.1145/3650212.3680379}
}