[论文解读] Do We Need Improved Code Quality Metrics?
本文批判了现有的代码质量度量标准,特别是针对内聚度量中的LCOM指标,并提出了一种更符合开发者直觉的新算法。基于8个不同案例的专家评估结果以及对超过90,000个Java类型的大规模定量分析,作者表明当前LCOM实现存在不严谨和误导性问题,而其新方法则能产生更准确且直观的内聚度量分数。
The software development community has been using code quality metrics for the last five decades. Despite their wide adoption, code quality metrics have attracted a fair share of criticism. In this paper, first, we carry out a qualitative exploration by surveying software developers to gauge their opinions about current practices and potential gaps with the present set of metrics. We identify deficiencies including lack of soundness, i.e., the ability of a metric to capture a notion accurately as promised by the metric, lack of support for assessing software architecture quality, and insufficient support for assessing software testing and infrastructure. In the second part of the paper, we focus on one specific code quality metric-LCOM as a case study to explore opportunities towards improved metrics. We evaluate existing LCOM algorithms qualitatively and quantitatively to observe how closely they represent the concept of cohesion. In this pursuit, we first create eight diverse cases that any LCOM algorithm must cover and obtain their cohesion levels by a set of experienced developers and consider them as a ground truth. We show that the present set of LCOM algorithms do poorly w.r.t. these cases. To bridge the identified gap, we propose a new approach to compute LCOM and evaluate the new approach with the ground truth. We also show, using a quantitative analysis using more than 90 thousand types belonging to 261 high-quality Java repositories, the present set of methods paint a very inaccurate and misleading picture of class cohesion. We conclude that the current code quality metrics in use suffer from various deficiencies, presenting ample opportunities for the research community to address the gaps.
研究动机与目标
- 调查现有代码质量度量标准在捕捉软件质量维度(如内聚性、架构、测试和基础设施)方面的局限性。
- 利用开发人员的实证判断作为真实数据,评估现有LCOM算法实现的严谨性和准确性。
- 提出一种新颖的LCOM计算算法,使其更符合面向对象类中内聚性的理论意图。
- 通过大规模实证分析证明,现有LCOM方法会产生误导性且不一致的内聚度量结果。
- 倡导开发更准确、领域特定的度量标准,并探讨机器学习作为传统度量方法的补充途径。
提出的方法
- 通过在线调查收集78名开发人员对现有代码质量度量标准的看法,识别其感知到的缺陷。
- 设计了八个多样化且具有代表性的类配置,作为评估内聚度量标准的测试用例。
- 从经验丰富的开发人员处收集每个测试用例的真实内聚度量分数,以建立基准。
- 将现有LCOM算法实现与开发人员提供的真实数据进行对比评估,以检验其准确性和严谨性。
- 基于对方法访问字段和内聚逻辑的改进处理,提出一种新的LCOM算法,并利用真实数据进行验证。
- 对261个高质量Java代码库(超过90,000个类型)进行大规模定量分析,比较不同LCOM变体的度量结果,评估其一致性和可靠性。
实验结果
研究问题
- RQ1现有LCOM算法在多大程度上准确反映了经验丰富的开发人员所感知的内聚性概念?
- RQ2当在多样化类配置上使用经开发人员验证的真实数据进行评估时,现有LCOM实现的表现如何?
- RQ3当前代码质量度量标准在评估软件架构、测试和基础设施质量方面存在哪些关键缺陷?
- RQ4能否设计一种新的LCOM算法,使其度量值更贴近人类直觉和专家判断?
- RQ5基于大规模实证分析,当前LCOM度量值在应用于真实世界软件系统时,其误导性程度如何?
主要发现
- 经专家开发人员判断验证,现有LCOM算法在80%的设计测试用例中未能正确体现内聚性。
- 所提出的新型LCOM算法在所有测试用例中均产生与经验开发人员建立的真实数据高度一致的度量值。
- 对261个高质量Java代码库中超过90,000个类型的定量分析表明,当前LCOM实现对类内聚性的刻画极不准确且极不一致。
- 研究发现现有LCOM实现存在严谨性不足的问题,与内聚性度量的理论意图存在显著偏差。
- 研究揭示了在评估软件架构、测试和基础设施质量方面,现有代码质量度量标准存在关键空白,这些方面缺乏有效支持。
- 研究结果表明,基于机器学习的方法可作为传统度量的补充,但前提是必须建立在实证验证和可操作洞察的基础上。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。