Page 237 - 《软件学报》2021年第8期
P. 237
黄子杰 等:检测 JavaScript 类的内聚耦合 Code Smell 2519
场景中,未被纳入考虑的情境因素可能降低代码异味强度的参考价值.这一问题可以通过实现情境感知的代码
优先级排序来解决,它综合考虑影响代码质量和重构优先级的多方面因素,代码异味强度是其中的一维特征 [39] .
5 结论和后续工作
JS 已成为最常用的编程语言之一,然而在 JS 项目中,仍未充分实现常见类 Code Smell 的检测.本文针对 DC、
FE 和 Blob 这 3 种 Code Smell,结合文本分析和代码结构静态分析,提出了一个检测 JS 类的内聚耦合 Code Smell
的方法 JS4C,并在实验部分,通过对 6 个开源项目的分析,证明了 JS4C 对内聚和耦合的设计问题有良好的检测
效果.
后续工作有 3 个方向:其一,研究的范围可以拓展到基于浏览器端框架的业务代码,检测与框架设计相关的
内聚耦合 Code Smell;其二,对大量的工业软件项目进行大样本的检测,进一步提高检测工具的稳定性和表现,并
对 Code Smell 及耦合、内聚问题进行详细的质性分析;其三,可以将结构检测和文本检测的结合方法进一步改
进,近期出现了基于深度学习模型、抽象语法树中的名称和结构特征及词向量分析代码功能的方法 [40] ,其对
Code Smell 检测的帮助也是值得研究的.
References:
[1] Fard AM, Mesbah A. Jsnose: Detecting JavaScript Code Smells. In: Proc. of the 13th Int’l Working Conf. on Source Code Analysis
and Manipulation. New York: IEEE, 2013. 116−125. [doi: 10.1109/SCAM.2013.6648192]
[2] Ocariza Jr FS, Pattabiraman K, Mesbah A. Detecting unknown inconsistencies in Web applications. In: Proc. of the 32nd IEEE/
ACM Int’l Conf. on Automated Software Engineering. New York: IEEE, 2017. 566−577. [doi: 10.1109/ASE.2017.8115667]
[3] Tufano M, Palomba F, Bavota G, Oliveto R, Di Penta M, De Lucia A, Poshyvanyk D. When and why your code starts to smell bad
(and whether the smells go away). IEEE Trans. on Software Engineering, 2017,43(11):1063−1088. [doi: 10.1109/TSE.2017.
2653105]
[4] Kostanjevec D, Pusnik M, Hericko M, Budimac Z. A preliminary empirical exploration of quality measurement for JavaScript
solutions. In: Proc. of the 6th Workshop of Software Quality, Analysis, Monitoring, Improvement, and Applications, Aachen
(CEUR-WS). 2017. 11−13.
[5] Saboury A, Musavi P, Khomh F, Bostjan S, Gordana R, Zoran B. An empirical study of Code Smells in JavaScript projects. In:
Proc. of the 24th Int’l Conf. on Software Analysis, Evolution and Reengineering. New York: IEEE, 2017. 294−305. [doi: 10.1109/
SANER.2017.7884630]
[6] Palomba F, Panichella A, Zaidman A, Oliveto R, De Lucia A. The scent of a smell: An extensive comparison between textual and
structural smells. IEEE Trans. on Software Engineering, 2017,44(10):977−1000. [doi: 10.1109/TSE.2017.2752171]
[7] Silva LH, Valente MT, Bergel A, Anquetil N, Etien A. Identifying classes in legacy JavaScript code. Journal of Software Evolution
and Process, 2017,29(8):Article No.e1864. [doi: 10.1002/smr.1864]
[8] Chahal KK, Singh H. Metrics to study symptoms of bad software designs. ACM SIGSOFT Software Engineering Notes, 2009,34(1):
1−4. [doi: 10.1145/1457516.1457522]
[9] Fowler M, Beck K. Refactoring: Improving the Design of Existing Code. 2nd ed., Boston: Addison-Wesley Professional, 2019.
[10] Fowler M. Refactoring a JavaScript video store. 2020. https://martinfowler.com/articles/refactoring-video-store-js/
[11] Inheritance and the prototype chain. 2020. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_
prototype_chain
[12] JS Classes. 2020. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
[13] Rostami S, Eshkevari L, Mazinanian D, Tsantalis N. Detecting function constructors in JavaScript. In: Proc. of the Int’l Conf. on
Software Maintenance and Evolution. New York: IEEE, 2016. 488−492. [doi: 10.1109/ICSME.2016.29]
[14] Lanza M, Marinescu R. Object-oriented Metrics in Practice: Using Software Metrics to Characterize, Evaluate, and Improve the
Design of Object-oriented Systems. Berlin: Springer Science and Business Media, 2007.
[15] Palomba F, Panichella A, De Lucia A, Oliveto R, Zaidman A. A textual-based technique for smell detection. In: Proc. of the 24th
Int’l Conf. on Program Comprehension. New York: IEEE, 2016. 1−10. [doi: 10.1109/ICPC.2016.7503704]