检测JavaScript类的内聚耦合Code Smell
作者:
作者单位:

作者简介:

黄子杰(1994-),男,博士生,CCF学生会员,主要研究领域为代码异味,软件可靠性,实证软件工程.
高建华(1968-),男,博士,教授,博士生导师,CCF高级会员,主要研究领域为软件重构,软件测试,可信软件,可靠性模型设计.
陈军华(1968-),男,副教授,主要研究领域为数据库理论及应用,分布式数据库.

通讯作者:

高建华,E-mail:jhgao@shnu.edu.cn

中图分类号:

TP311

基金项目:

国家自然科学基金(61672355)


Detecting Coupling and Cohesion Code Smells of JavaScript Classes
Author:
Affiliation:

Fund Project:

National Natural Science Foundation of China (61672355)

  • 摘要
  • |
  • 图/表
  • |
  • 访问统计
  • |
  • 参考文献
  • |
  • 相似文献
  • |
  • 引证文献
  • |
  • 资源附件
  • |
  • 文章评论
    摘要:

    Code Smell是软件程序中存在不良设计和不良实现的征兆.正确地检测和识别Code Smell可以指导软件重构,提高软件的可用性和可靠性.通过Code Smell的度量指标,可以量化软件的设计问题.JavaScript已成为最常用的编程语言之一,类是JavaScript的设计模式,优秀类的设计体现为高内聚和低耦合.现有关于JavaScript内聚耦合的Code Smell研究均在微观的层面,即函数和语句上进行.它们可以提供程序实现的重构建议,但无法分析内聚耦合相关的软件系统设计问题.针对FE、DC和Blob这3种类的内聚耦合Code Smell,提出一种JavaScript类的内聚耦合Code Smell检测方法JS4C.该方法基于静态分析,同时适用于客户端和服务端程序.它通过遍历软件系统中所有的类,利用源程序的文本相似度特征和结构特征,识别Code Smell并检测其强度.在结构特征检测中,JS4C使用了经扩展的对象类型推断及非严格的耦合分散度度量法NSCDISP,有效地降低了解释型语言的静态分析过程中,类型信息缺失对检测产生的影响.实验通过对6个开源项目的分析表明,JS4C对内聚耦合设计问题有良好的检测效果.

    Abstract:

    Code Smells are symptoms of poor design and implementation choices. Detect and identify Code Smell precisely provide guidance on software refactoring, and lead to improvement of software usability and reliability. Design problems of software systems could be quantified through Code Smell metrics. JavaScript has become one of the most widely used programming languages, class is a design pattern of JavaScript, loose coupling and strong cohesion are characteristics of a well-designed class. Prior works measured coupling and cohesion Code Smells of JS programs in lower levels, i.e., function-wide and statement-wide, which were capable for providing refactoring suggestions about basic implementations, but not enough to identify design problems. This paper proposed JS4C, a method to detect coupling and cohesion Code Smells of JS classes including FE, DC and Blob. This method is an approach of static analysis works on both server and client-side applications, it iterates over every class in software system and takes advantage of source code textual patterns. While JS4C detects Code Smells, it also determines intensity for each of them. Missing type information in static analysis is reinforced by extended object type inference and non-strict coupling dispersion (NSCDISP) metric during structural analysis. Experiments made on 6 open-sourced projects indicate that JS4C can correctly detect coupling and cohesion design problems.

    参考文献
    相似文献
    引证文献
引用本文

黄子杰,陈军华,高建华.检测JavaScript类的内聚耦合Code Smell.软件学报,2021,32(8):2505-2521

复制
分享
文章指标
  • 点击次数:
  • 下载次数:
  • HTML阅读次数:
  • 引用次数:
历史
  • 收稿日期:2018-10-31
  • 最后修改日期:2020-04-25
  • 录用日期:
  • 在线发布日期: 2021-08-05
  • 出版日期: 2021-08-06
您是第位访问者
版权所有:中国科学院软件研究所 京ICP备05046678号-3
地址:北京市海淀区中关村南四街4号,邮政编码:100190
电话:010-62562563 传真:010-62562533 Email:jos@iscas.ac.cn
技术支持:北京勤云科技发展有限公司

京公网安备 11040202500063号