一句话:识别8种JavaScript Promise反模式,提出轻量静态分析并集成动态分析的可视化工具。
Promise与async/await已成为JavaScript中实现异步计算的流行机制,但程序员仍难以正确使用。本文在流行JavaScript仓库中总结出8种常见的promise反模式,并提出一种轻量级静态分析来自动检测它们。该分析被嵌入一个交互式可视化工具,并额外依赖动态分析来展示promise生命周期以及运行时执行到的反模式实例。用户可以在可视化中的promise与其原始源码片段之间导航,从而识别问题和优化机会。
Promises and async/await have become popular mechanisms for implementing asynchronous computations in JavaScript, but despite their popularity, programmers have difficulty using them. This paper identifies 8 anti-patterns in promise-based JavaScript code that are prevalent across popular JavaScript repositories. We present a light-weight static analysis for automatically detecting these anti-patterns. This analysis is embedded in an interactive visualization tool that additionally relies on dynamic analysis to visualize promise lifetimes and instances of anti-patterns executed at run time. By enabling the user to navigate between promises in the visualization and the source code fragments that they originate from, problems and optimization opportunities can be identified.