Recommending Variable Names for Extract Local Variable Refactorings

📅 2025-06-30
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
Existing IDEs provide variable naming suggestions for local variable extraction refactoring with only ~30% alignment to developers’ naming conventions, necessitating frequent manual renaming and thereby impeding refactoring efficiency and code readability. To address this, we propose VarNamer—a novel variable naming recommendation approach that synergistically integrates static program analysis with data-driven mining. VarNamer identifies semantically critical contextual elements (e.g., defining expressions, usage patterns, and scope constraints) and applies lightweight, domain-informed heuristics to generate accurate, generalizable names. Implemented as an Eclipse plugin, VarNamer was rigorously evaluated via large-scale empirical analysis of real-world projects and controlled user studies. Results show that VarNamer improves exact-match naming accuracy by 52.6% over Eclipse’s built-in recommender and by 40.7% over IntelliJ IDEA’s, while reducing average refactoring time by 27.8% and decreasing naming-related editing operations by 49.3%.

Technology Category

Application Category

📝 Abstract
Extract local variable is one of the most popular refactorings, and most IDEs and refactoring tools provide automated support for this refactoring. However, we find approximately 70% of the names recommended by these IDEs are different from what developers manually constructed, adding additional renaming burdens to developers and providing limited assistance. In this paper, we introduce VarNamer, an automated approach designed to recommend variable names for extract local variable refactorings. Through a large-scale empirical study, we identify key contexts that are useful for composing variable names. Leveraging these insights, we developed a set of heuristic rules through program static analysis techniques and employ data mining techniques to recommend variable names effectively. Notably, some of our heuristic rules have been successfully integrated into Eclipse, where they are now distributed with the latest releases of the IDE. Evaluation demonstrates its superiority over state-of-the-art IDEs. Specifically, VarNamer significantly increases the chance of exact match by 52.6% compared to Eclipse and 40.7% compared to IntelliJ IDEA. We also evaluated the proposed approach with real-world extract local variable refactorings conducted in C++ projects, and the results suggest that the approach can achieve comparable performance on programming languages besides Java. It may suggest the generalizability of VarNamer. Finally, we designed and conducted a user study and the results of the user study suggest that our approach can speed up the refactoring by 27.8% and reduce 49.3% edits on the recommended variable names.
Problem

Research questions and friction points this paper is trying to address.

Improving variable name recommendations for extract local variable refactorings
Reducing renaming burdens caused by IDE-suggested variable names
Enhancing refactoring efficiency with data-driven name suggestions
Innovation

Methods, ideas, or system contributions that make the work stand out.

VarNamer uses static analysis for name recommendations
Data mining enhances variable name suggestion accuracy
Heuristic rules integrated into Eclipse improve performance
🔎 Similar Papers
No similar papers found.
T
Taiming Wang
School of Computer Science & Technology, Beijing Institute of Technology, China
H
Hui Liu
School of Computer Science & Technology, Beijing Institute of Technology, China
Y
Yuxia Zhang
School of Computer Science & Technology, Beijing Institute of Technology, China
Yanjie Jiang
Yanjie Jiang
Tianjin University
software refactoring and testing