ReInstancer: An automatic refactoring approach for Instanceof pattern matching

IF 1.8 4区 计算机科学 Q3 COMPUTER SCIENCE, SOFTWARE ENGINEERING Journal of Software-Evolution and Process Pub Date : 2024-03-12 DOI:10.1002/smr.2661
Yang Zhang, Shuai Hong
{"title":"ReInstancer: An automatic refactoring approach for Instanceof pattern matching","authors":"Yang Zhang,&nbsp;Shuai Hong","doi":"10.1002/smr.2661","DOIUrl":null,"url":null,"abstract":"<p>The <i>instanceof</i> pattern matching can improve the code quality and readability by removing the redundant typecasting and simplifying the design in different scenarios. However, existing works do not provide sufficient support for refactoring <i>instanceof</i> pattern matching. This paper first identifies several cases that cannot be well handled by existing IDEs. Based on these observations, we propose a novel approach called <i>ReInstancer</i> to refactor <i>instanceof</i> pattern matching automatically. <i>ReInstancer</i> conducts program analysis for multi-branch statements to obtain pattern variables. After analyzing these patterns, the multi-branch statements are optimized and finally refactored into <i>switch</i> statements or expressions. <i>ReInstancer</i> is evaluated by 20 real-world projects with more than 7,700 <i>instanceof</i> pattern matching. The experimental results demonstrate that a total of 3,558 <i>instanceof</i> expressions and 228 multi-branch statements are refactored within 10.8 s on average for each project. <i>ReInstancer</i> improves the code quality by reducing redundant typecasting, demonstrating its effectiveness.</p>","PeriodicalId":48898,"journal":{"name":"Journal of Software-Evolution and Process","volume":"36 8","pages":""},"PeriodicalIF":1.8000,"publicationDate":"2024-03-12","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Journal of Software-Evolution and Process","FirstCategoryId":"94","ListUrlMain":"https://onlinelibrary.wiley.com/doi/10.1002/smr.2661","RegionNum":4,"RegionCategory":"计算机科学","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"Q3","JCRName":"COMPUTER SCIENCE, SOFTWARE ENGINEERING","Score":null,"Total":0}
引用次数: 0

Abstract

The instanceof pattern matching can improve the code quality and readability by removing the redundant typecasting and simplifying the design in different scenarios. However, existing works do not provide sufficient support for refactoring instanceof pattern matching. This paper first identifies several cases that cannot be well handled by existing IDEs. Based on these observations, we propose a novel approach called ReInstancer to refactor instanceof pattern matching automatically. ReInstancer conducts program analysis for multi-branch statements to obtain pattern variables. After analyzing these patterns, the multi-branch statements are optimized and finally refactored into switch statements or expressions. ReInstancer is evaluated by 20 real-world projects with more than 7,700 instanceof pattern matching. The experimental results demonstrate that a total of 3,558 instanceof expressions and 228 multi-branch statements are refactored within 10.8 s on average for each project. ReInstancer improves the code quality by reducing redundant typecasting, demonstrating its effectiveness.

Abstract Image

Abstract Image

查看原文
分享 分享
微信好友 朋友圈 QQ好友 复制链接
本刊更多论文
ReInstancer:针对 Instanceof 模式匹配的自动重构方法
instanceof 模式匹配可以去除多余的类型转换,简化不同场景下的设计,从而提高代码质量和可读性。然而,现有的工作并没有为重构 instanceof 模式匹配提供足够的支持。本文首先确定了现有集成开发环境无法很好处理的几种情况。基于这些观察结果,我们提出了一种名为 ReInstancer 的新方法,用于自动重构 instanceof 模式匹配。ReInstancer 对多分支语句进行程序分析,以获取模式变量。分析这些模式后,多分支语句将被优化,并最终重构为开关语句或表达式。ReInstancer 在 20 个实际项目中进行了评估,模式匹配实例超过 7,700 个。实验结果表明,每个项目平均在 10.8 秒内重构了 3,558 个 instanceof 表达式和 228 个多分支语句。ReInstancer 通过减少冗余类型铸造提高了代码质量,证明了它的有效性。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 去求助
来源期刊
Journal of Software-Evolution and Process
Journal of Software-Evolution and Process COMPUTER SCIENCE, SOFTWARE ENGINEERING-
自引率
10.00%
发文量
109
期刊最新文献
An Integrated Cybersecurity Framework for Software Development and Risk-Aware Practices in the SDLC Exploring the Relationship Between Trait Emotional Intelligence and Performance in the Context of SME Software Engineering Issue Information PathCovAVTest: Testing for Violations of Autonomous Driving Systems Based on Path Coverage of Traffic Regulation Scenarios i-SYNERGY: An Integrated Predictive Model for Assessing Software Developers' Performance Under Time Pressure
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
现在去查看 取消
×
提示
确定
0
微信
客服QQ
Book学术公众号 扫码关注我们
反馈
×
意见反馈
请填写您的意见或建议
请填写您的手机或邮箱
已复制链接
已复制链接
快去分享给好友吧!
我知道了
×
扫码分享
扫码分享
Book学术官方微信
Book学术文献互助
Book学术文献互助群
群 号:604180095
Book学术
文献互助 智能选刊 最新文献 互助须知 联系我们:info@booksci.cn
Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。
Copyright © 2023 Book学术 All rights reserved.
ghs 京公网安备 11010802042870号 京ICP备2023020795号-1