Automated Refactoring of Legacy JavaScript Code to ES6 Modules

07/21/2021
by   Katerina Paltoglou, et al.
0

The JavaScript language did not specify, until ECMAScript 6 (ES6), native features for streamlining encapsulation and modularity. Developer community filled the gap with a proliferation of design patterns and module formats, with impact on code reusability, portability and complexity of build configurations. This work studies the automated refactoring of legacy ES5 code to ES6 modules with fine-grained reuse of module contents through the named import/export language constructs. The focus is on reducing the coupling of refactored modules through destructuring exported module objects to fine-grained module features and enhancing module dependencies by leveraging the ES6 syntax. We employ static analysis to construct a model of a JavaScript project, the Module Dependence Graph (MDG), that represents modules and their dependencies. On the basis of MDG we specify the refactoring procedure for module migration to ES6. A prototype implementation has been empirically evaluated on 19 open source projects. Results highlight the relevance of the refactoring with a developer intent for fine-grained reuse. The analysis of refactored code shows an increase in the number of reusable elements per project and reduction in the coupling of refactored modules. The soundness of the refactoring is empirically validated through code inspection and execution of projects' test suites.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
02/08/2022

A Novel Plug-in Module for Fine-Grained Visual Classification

Visual classification can be divided into coarse-grained and fine-graine...
research
04/02/2021

Feature Evolution and Reuse – An Exploratory Study of Eclipse

One of the purported ways to increase productivity and reduce developmen...
research
03/11/2023

Fine-grained Visual Classification with High-temperature Refinement and Background Suppression

Fine-grained visual classification is a challenging task due to the high...
research
10/02/2021

The Need for a Fine-grained approach in Just-in-Time Defect Prediction

With software system complexity leading to the rise of software defects,...
research
07/14/2023

Complementary Frequency-Varying Awareness Network for Open-Set Fine-Grained Image Recognition

Open-set image recognition is a challenging topic in computer vision. Mo...
research
04/05/2018

An Approach to Incremental and Modular Context-sensitive Analysis

Context-sensitive global analysis of large code bases can be expensive, ...
research
04/05/2018

An Approach to Incremental and Modular Context-sensitive Analysis of Logic Programs

Context-sensitive global analysis of large code bases can be expensive, ...

Please sign up or login with your details

Forgot password? Click here to reset