跳到主要导航 跳到搜索 跳到主要内容

Extracting Conditional Expressions as Local Variables: Frequency, Motivation, and Automated Recommendation

  • Bridget Nyirongo
  • , Yanjie Jiang*
  • , Yuxia Zhang
  • , Hui Liu
  • *此作品的通讯作者
  • Beijing Institute of Technology
  • Tianjin University

科研成果: 期刊稿件文章同行评审

摘要

Software refactoring is essential for improving code readability and maintainability while reducing technical debt. Applying the extract local variable refactoring to condition expressions can simplify complex logic, enhance clarity, and reduce control-flow complexity. However, despite these benefits, mainstream IDEs and recent tool enhancements lack targeted, context-aware recommendations for this specific transformation. Understanding the patterns and contextual factors driving such extractions is necessary to augment existing tools with heuristics that promote meaningful and maintainable changes. To address this gap, this paper presents the first empirical study of extract local variable refactorings applied to conditional expressions, analyzing 984 instances across ten popular open-source Java projects. Our analysis shows that approximately 10.1% of extract local variable refactorings target condition expressions, highlighting their non-trivial presence in real-world projects. Through a two-round questionnaire survey, we identify and prioritize seven key motivations for applying extract variable to condition expressions, offering insight into developer intent. We further identify and validate twenty recurring features of such expressions, informing a set of practical heuristics that provide structural signals for suggesting this refactoring. Building on these findings, we introduce ConExtractor, a hybrid recommendation prototype combining heuristics with LLM evaluation. Across multiple LLM configurations, the hybrid approach achieves precision up to 96.7% and recall up to 88%, demonstrating its potential to provide selective and developer-aligned refactoring suggestions in practice.

源语言英语
期刊IEEE Transactions on Software Engineering
DOI
出版状态已接受/待刊 - 2026
已对外发布

学术指纹

探究 'Extracting Conditional Expressions as Local Variables: Frequency, Motivation, and Automated Recommendation' 的科研主题。它们共同构成独一无二的学术指纹。

引用此