arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1703.01690cs.SEcs.PL
收藏

重构遗留JavaScript代码以使用类:好的、坏的和丑陋的

Refactoring Legacy JavaScript Code to Use Classes: The Good, The Bad and The Ugly

Leonardo Humberto Silva, Marco Tulio Valente, Alexandre Bergel

摘要:

JavaScript系统正变得越来越复杂和庞大。为了解决实现这些系统所涉及的挑战,该语言正在发展,以包括几个用于大型编程的结构。例如,尽管语言是基于原型的,但最新的JavaScript标准,名为ECMAScript 6(ES6),提供了对实现类的本机支持。尽管大多数现代Web浏览器都支持ES6,但只有极少数应用程序使用类语法。在本文中,我们分析了迁移结构的过程,这些结构模拟遗留JavaScript代码中的类,以采用ES6引入的类的新语法。我们在八个遗留JavaScript系统上应用一组迁移规则。在我们的研究中,我们记录了:(a)迁移简单的情况(好的部分);(b)需要手动和临时迁移的情况(坏的部分);以及(c)由于ES6的限制和约束而无法迁移的情况(丑陋的部分)。八分之六的系统(75%)包含坏的和/或丑陋的情况。我们还收集了JavaScript开发人员对迁移代码以使用新的类语法的看法。

英文摘要:

JavaScript systems are becoming increasingly complex and large. To tackle the challenges involved in implementing these systems, the language is evolving to include several constructions for programming- in-the-large. For example, although the language is prototype-based, the latest JavaScript standard, named ECMAScript 6 (ES6), provides native support for implementing classes. Even though most modern web browsers support ES6, only a very few applications use the class syntax. In this paper, we analyze the process of migrating structures that emulate classes in legacy JavaScript code to adopt the new syntax for classes introduced by ES6. We apply a set of migration rules on eight legacy JavaScript systems. In our study, we document: (a) cases that are straightforward to migrate (the good parts); (b) cases that require manual and ad-hoc migration (the bad parts); and (c) cases that cannot be migrated due to limitations and restrictions of ES6 (the ugly parts). Six out of eight systems (75%) contain instances of bad and/or ugly cases. We also collect the perceptions of JavaScript developers about migrating their code to use the new syntax for classes.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑