Back to Search Start Over

ReInstancer: An automatic refactoring approach for Instanceof pattern matching.

Authors :
Zhang, Yang
Hong, Shuai
Source :
Journal of Software: Evolution & Process. Aug2024, Vol. 36 Issue 8, p1-17. 17p.
Publication Year :
2024

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 FROM AUTHOR]

Subjects

Subjects :
*CONTENT analysis

Details

Language :
English
ISSN :
20477473
Volume :
36
Issue :
8
Database :
Academic Search Index
Journal :
Journal of Software: Evolution & Process
Publication Type :
Academic Journal
Accession number :
178853975
Full Text :
https://doi.org/10.1002/smr.2661