Recommending Variable Names for Extract Local Variable Refactorings

重构代码 计算机科学 变量(数学) Java 日食 启发式 语法 集合(抽象数据类型) 程序设计语言 人工智能 软件 数学 天文 物理 数学分析
作者
Taiming Wang,Hui Liu,Yuxia Zhang,Yanjie Jiang
出处
期刊:ACM Transactions on Software Engineering and Methodology [Association for Computing Machinery]
卷期号:34 (6): 1-38
标识
DOI:10.1145/3712191
摘要

Extract local variable is one of the most popular refactorings. It is frequently employed to replace occurrences of a complex expression with simple accesses to a newly introduced variable that is initialized by the original complex expression. Consequently, most IDEs and refactoring tools provide automated support for this refactoring, e.g., to suggest names for the newly extracted variables. 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 article, 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, such as variable initializations and homogeneous variables (variables whose initializations are identical to that of the newly extracted variable), that are useful for composing variable names. Leveraging these insights, we developed a set of heuristic rules through program static analysis techniques, e.g., lexical analysis, syntax analysis, control flow analysis, and data flow analysis, and employ data mining techniques, i.e., FP-growth algorithm, 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 of VarNamer on a dataset of 27,158 real-world extract local variable refactorings in Java applications 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 to investigate the impact of VarNamer on developers’ productivity. 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.
最长约 10秒,即可获得该文献文件

科研通智能强力驱动
Strongly Powered by AbleSci AI
科研通是完全免费的文献互助平台,具备全网最快的应助速度,最高的求助完成率。 对每一个文献求助,科研通都将尽心尽力,给求助人一个满意的交代。
实时播报
一行琉璃发布了新的文献求助150
刚刚
孙同学发布了新的文献求助10
2秒前
ddd完成签到,获得积分10
4秒前
灵巧幻露完成签到,获得积分10
6秒前
挣积分换文献的大飞完成签到,获得积分10
6秒前
mxm完成签到,获得积分10
8秒前
12305014077完成签到 ,获得积分10
9秒前
王昕钥完成签到,获得积分10
11秒前
于适女朋友完成签到,获得积分10
11秒前
tudouning完成签到,获得积分10
13秒前
14秒前
华仔应助mahua采纳,获得10
15秒前
CACT完成签到,获得积分10
15秒前
16秒前
17秒前
干净的南烟完成签到,获得积分10
17秒前
阴沟里的麻薯完成签到,获得积分10
18秒前
maclogos完成签到,获得积分10
19秒前
光之霓裳完成签到 ,获得积分0
19秒前
做的出来完成签到,获得积分10
20秒前
21秒前
hu完成签到,获得积分10
21秒前
舒适映寒完成签到,获得积分10
21秒前
1199完成签到 ,获得积分10
22秒前
研友_Z1eDgZ发布了新的文献求助10
22秒前
王小鱼完成签到 ,获得积分10
22秒前
tao完成签到 ,获得积分10
23秒前
lilyyang完成签到,获得积分10
23秒前
11111111111完成签到,获得积分10
24秒前
炙热夜绿完成签到 ,获得积分10
25秒前
orange完成签到,获得积分10
25秒前
小二郎应助正能量的涛采纳,获得10
25秒前
sql完成签到,获得积分10
26秒前
思源应助chrysan采纳,获得10
29秒前
招水若离完成签到,获得积分0
30秒前
南枳完成签到 ,获得积分10
30秒前
酷波er应助阴沟里的麻薯采纳,获得20
31秒前
cdercder应助wxhzsdvv采纳,获得10
31秒前
外向的烟完成签到,获得积分10
32秒前
chy完成签到 ,获得积分10
32秒前
高分求助中
(应助此贴封号)【重要!!请各用户(尤其是新用户)详细阅读】【科研通的精品贴汇总】 10000
China Pluperfect I: Epistemology of Past and Outside in Chinese Art 520
Matrix Methods in Data Mining and Pattern Recognition Second Edition 510
基于锂离子电池正极材料回收的绿色溶剂开发及工程化应用研究 500
Auslegungsgeschichte 500
Transdermal drug delivery systems market size report 500
Cosmos as Art Object: Studies in Plato's Timaeus and Other Dialogues 500
热门求助领域 (近24小时)
化学 材料科学 医学 生物 纳米技术 工程类 有机化学 化学工程 生物化学 计算机科学 内科学 物理 复合材料 催化作用 细胞生物学 无机化学 光电子学 物理化学 电极 基因
热门帖子
关注 科研通微信公众号,转发送积分 7640861
求助须知:如何正确求助?哪些是违规求助? 9213888
关于积分的说明 19764092
捐赠科研通 7206571
什么是DOI,文献DOI怎么找? 3276166
关于科研通互助平台的介绍 2437790
邀请新用户注册赠送积分活动 2273653