[Paper Review] Do We Need Improved Code Quality Metrics?
This paper critiques existing code quality metrics, particularly focusing on the LCOM metric for cohesion, and proposes a new algorithm that better aligns with developer intuition. Using a ground truth from expert assessments across 8 diverse cases and quantitative analysis of 90,000+ Java types, the authors show current LCOM implementations are unsound and misleading, while their new approach produces more accurate and intuitive cohesion scores.
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.
Motivation & Objective
- To investigate the limitations of current code quality metrics in capturing software quality dimensions such as cohesion, architecture, testing, and infrastructure.
- To evaluate the soundness and accuracy of existing LCOM algorithm implementations using empirical developer judgments as ground truth.
- To propose a novel LCOM computation algorithm that better reflects the theoretical intent of cohesion in object-oriented classes.
- To demonstrate through large-scale empirical analysis that existing LCOM methods produce misleading and inconsistent cohesion measurements.
- To advocate for the development of more accurate, domain-specific metrics and explore machine learning as a complementary approach to traditional metrics.
Proposed method
- Conducted an online survey with 78 developers to gather opinions on current code quality metrics and identify perceived shortcomings.
- Designed eight diverse, representative class configurations to serve as test cases for evaluating cohesion metrics.
- Collected ground truth cohesion scores from experienced developers for each of the eight test cases to establish a benchmark.
- Implemented and evaluated existing LCOM algorithms against the developer-provided ground truth to assess their accuracy and soundness.
- Proposed a new LCOM algorithm based on improved handling of method-accessed fields and cohesion logic, validated against the ground truth.
- Performed a large-scale quantitative analysis on 261 high-quality Java repositories (90,000+ types) to compare metric outputs across different LCOM variants and assess their consistency and reliability.
Experimental results
Research questions
- RQ1To what extent do current LCOM algorithms accurately reflect the cohesion concept as perceived by experienced developers?
- RQ2How do existing LCOM implementations perform when evaluated against a developer-validated ground truth across diverse class configurations?
- RQ3What are the key deficiencies in current code quality metrics related to assessing software architecture, testing, and infrastructure quality?
- RQ4Can a new LCOM algorithm be designed that produces metric values closer to human intuition and expert judgment?
- RQ5How misleading are the current LCOM metric values when applied to real-world software systems, based on large-scale empirical analysis?
Key findings
- Existing LCOM algorithms fail to correctly represent cohesion in 80% of the designed test cases, as validated by expert developer judgments.
- The proposed new LCOM algorithm produces metric values that align closely with the ground truth established by experienced developers across all test cases.
- Quantitative analysis of 90,000+ types from 261 high-quality Java repositories reveals that current LCOM implementations paint a highly inaccurate and inconsistent picture of class cohesion.
- The study identifies a lack of soundness in current LCOM implementations, with significant deviations from the theoretical intent of measuring cohesion.
- The research highlights a critical gap in code quality metrics for assessing software architecture, testing, and infrastructure, which are under-supported by existing metrics.
- The findings suggest that machine learning-based approaches could complement traditional metrics, but only if grounded in empirical validation and actionable insights.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.