paperbot · PL 论文追踪

全部论文 待读 收藏

P2 A Position-Aware Approach to Decomposing God Classes

一种位置感知的 God Class 分解方法
ASE Proceedings of the 39th IEEE/ACM International Conference on Automated Software Engineering2024匹配度 1/10 · 论文聚焦 God Class 分解重构,基于代码度量、物理位置聚类和字段分配,属于软件工程/重构方向;不涉及 LLM/Agent、机器学习程序静态分析、浮点程序分析或贝叶斯程序分析,与用户画像核心方向基本无关。引用 2 inbox
Tianyi Chen, Yanjie Jiang, Fu Fan, Bo Liu, Hui Liu
crossref: 2026-09-12

AI 速览

一句话:提出位置感知的 ClassSplitter,结合代码度量与物理位置聚类及字段分配,自动分解 God Class。

God Class 会损害代码可维护性与可读性,但自动且准确地分解它们仍很困难。本文提出 ClassSplitter,其核心观察是物理位置相近的方法和字段往往语义相关。作者先分析 54 个真实 God Class 分解重构以验证该假设,然后在相似度中同时考虑传统代码度量和实体相对物理位置,定制聚类算法对 God Class 内方法分组,再根据字段访问耦合将字段分配到新类。基于 133 个开源应用中的真实 God Class 评估,ClassSplitter 将平均 MoJoFM 提升 47%;人工评估中,77% 的情况下开发者更偏好其建议。

问题
God Class 是常见代码坏味,人工分解成本高,现有自动分解工具仍不够准确。
方法
利用方法/字段物理相邻性与语义相关性的观察,融合代码度量和相对位置计算实体相似度,定制聚类算法划分方法,并按字段访问耦合分配字段。
评估
在 133 个真实开源 God Class 上评估,与 SOTA 基线比较 MoJoFM 和开发者人工偏好。
原文摘要(Abstract)

God classes are widely recognized as code smells, significantly impairing the maintainability and readability of source code. However, resolving the identified God classes remains a formidable challenge, and we still lack automated and accurate tools to resolve God classes automatically. To this end, in this paper, we propose a novel approach (called ClassSplitter) to decompose God classes. The key observation behind the proposed approach is that software entities (i.e., methods and fields) that are physically adjacent often have strong semantic correlations and thus have a great chance of being classified into the same class during God class deposition. We validate this hypothesis by analyzing 54 God class decomposition refactorings actually conducted in the wild. According to the observation, we measure the similarity between software entities by exploiting not only traditional code metrics but also their relative physical positions. Based on the similarity, we customize a clustering algorithm to classify the methods within a given God class, and each of the resulting clusters is taken as a new class. Finally, ClassSplitter allocates the fields of the God class to the new classes according to the field-access-based coupling between fields and classes. We evaluate ClassSplitter using 133 real-world God classes from open-source applications. Our evaluation results suggest that ClassSplitter could substantially improve the state of the art in God class decomposition, improving the average MoJoFM by 47%. Manual evaluation also confirmed that in most cases (77%) the solutions suggested by ClassSplitter were preferred by developers to alternatives suggested by the state-of-the-art baseline approach.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot8318,
  title = {A Position-Aware Approach to Decomposing God Classes},
  author = {Tianyi Chen and Yanjie Jiang and Fu Fan and Bo Liu and Hui Liu},
  booktitle = {ASE},
  year = {2024},
  doi = {10.1145/3691620.3694992}
}