A Position-Aware Approach to Decomposing God Classes

Tianyi Chen*, Yanjie Jiang, Fu Fan, Bo Liu, Hui Liu*

*Corresponding author for this work

Research output: Chapter in Book/Report/Conference proceedingConference contributionpeer-review

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.

Original languageEnglish
Title of host publicationProceedings - 2024 39th ACM/IEEE International Conference on Automated Software Engineering, ASE 2024
PublisherAssociation for Computing Machinery, Inc
Pages129-140
Number of pages12
ISBN (Electronic)9798400712487
DOIs
Publication statusPublished - 27 Oct 2024
Event39th ACM/IEEE International Conference on Automated Software Engineering, ASE 2024 - Sacramento, United States
Duration: 28 Oct 20241 Nov 2024

Publication series

NameProceedings - 2024 39th ACM/IEEE International Conference on Automated Software Engineering, ASE 2024

Conference

Conference39th ACM/IEEE International Conference on Automated Software Engineering, ASE 2024
Country/TerritoryUnited States
CitySacramento
Period28/10/241/11/24

Keywords

  • code smells
  • god class
  • large language model
  • software refactoring

Fingerprint

Dive into the research topics of 'A Position-Aware Approach to Decomposing God Classes'. Together they form a unique fingerprint.

Cite this

Chen, T., Jiang, Y., Fan, F., Liu, B., & Liu, H. (2024). A Position-Aware Approach to Decomposing God Classes. In Proceedings - 2024 39th ACM/IEEE International Conference on Automated Software Engineering, ASE 2024 (pp. 129-140). (Proceedings - 2024 39th ACM/IEEE International Conference on Automated Software Engineering, ASE 2024). Association for Computing Machinery, Inc. https://doi.org/10.1145/3691620.3694992