Lune

ASE2024Top-tier venue

Three Heads Are Better Than One: Suggesting Move Method Refactoring Opportunities with Inter-class Code Entity Dependency Enhanced Hybrid Hypergraph Neural Network

Di Cui, Jiaqi Wang, Qiangqiang Wang, Peng Ji, Minglang Qiao, Yutong Zhao, Jingzhao Hu, Luqiao Wang, Qingshan Li

Abstract

Methods implemented in incorrect classes will cause excessive reliance on other classes than their own, known as a typical code smell symptom: feature envy, which makes it difficult to maintain increased coupling between classes. Addressing this issue, several Move Method refactoring tools have been proposed, employing a two-phase process: identifying misplaced methods to move and appropriate classes to receive, and implementing the mechanics of refactoring. These tools traditionally use hard-coded metrics to measure correlations between movable methods and target classes and apply heuristic thresholds or trained classifiers to unearth refactoring opportunities. Yet, these approaches predominantly illuminate pairwise correlations between methods and classes while overlooking the complex and complicated dependencies binding multiple code entities within these methods/classes that are prevalent in real-world cases. This narrow focus can lead to refactoring suggestions that may diverge from developers' actual needs. To bridge this gap, our paper leverages the concept of inter-class code entity dependency hypergraph to model complicated dependency relationships involving multiple code entities within various methods/classes and proposes a hypergraph learning-based approach to suggest Move Method refactoring opportunities named HMove. We first construct inter-class code entity dependency hypergraphs from training samples and assign attributes to entities with a pre-trained code model. All the attributed hypergraphs are fed into a hybrid hypergraph neural network for training. Utilizing this trained neural network alongside a large language model, we construct a refactoring suggestion system. We trained HMove on a large-scale dataset and evaluated it on two real-world datasets. The results show that demonstrates an increase of 27.8% in precision, 2.5% in recall, and 18.5% in f1-measure compared to 9 state-of-the-art refactoring tools, which is more useful for 68% of participants. The results also unveil practical suggestions and new insights that benefit existing feature envy-related refactoring techniques.

Ask Lune

Know where this paper stands in minutes, not an afternoon.

Lune can read the top-tier papers that cite it and the ones closest to it, and tells you what it claims, what came after and where it falls short, each point cited to the paper it comes from. No skimming, no AI slop.

Questions to start from

Lune can draw on

its abstract · related work

Get the answer

Free to start. No credit card required.

Related papers

  1. One-to-One or One-to-Many? Suggesting Extract Class Refactoring Opportunities with Intra-class Dependency Hypergraph Neural NetworkDi Cui, Qiangqiang Wang, Yutong Zhao, Jiaqi Wang et al.ISSTA 2024 · 4 citations
  2. Deep Learning Based Feature Envy Detection Boosted by Real-World ExamplesBo Liu, Hui Liu, Guangjie Li, Nan Niu et al.FSE 2023 · 19 citations
  3. iSMELL: Assembling LLMs with Expert Toolsets for Code Smell Detection and RefactoringDi Wu, Fangwen Mu, Lin Shi, Zhaoqiang Guo et al.ASE 2024 · 19 citations
  4. HGAdapter: Hypergraph-based Adapters in Language Models for Code Summarization and Clone DetectionGuang Yang, Yujie ZhuEMNLP Findings 2025
  5. Graph Neural Network to Dilute Outliers for Refactoring Monolith ApplicationUtkarsh Desai, Sambaran Bandyopadhyay, Srikanth TamilselvamAAAI 2021 · 84 citations
Dusk over the sea between two cliffs drawn in fine vertical lines