Study validates common class-level object-oriented code quality measures
Assessing the Construct Validity of Object-Oriented, Class-Level Code Quality Metrics
Software Engineering
Summary
Measuring software code quality helps developers keep their programs healthy, but it is unclear if common measurements truly capture what they claim. The authors analyzed many code quality metrics from a large project and several other open source projects to check if these metrics relate to clear concepts like coupling, cohesion, size, and inheritance. They found that many metrics do align with distinct quality aspects, while some do not. The results help confirm which metrics reliably measure code quality and refine the understanding of complex traits like coupling and inheritance.
What this means in practice
- •For software quality engineers: Use validated metrics to more accurately assess and monitor object-oriented code quality during software development cycles.
- •For software project managers: Choose appropriate quality metrics for project evaluation by relying on verified relationships among code characteristics to guide decision-making.
Authors
Hera Arif, Miikka Kuutila, Paul Ralph
Abstract
Background: Code quality metrics are intended to measure latent properties of software source code. Although numerous code metrics have been proposed and used, their construct validity is rarely evaluated. Thus, the extent to which code metrics actually measure what they claim to measure is often unclear. Aim: Drawing from modern measurement theory, we investigate the construct validity of common class-level, object-oriented code quality metrics by identifying their factor structure using Exploratory Factor Analysis (EFA). The metrics were extracted from the Apache Maven project by three software tools: Designite, JHawk, and Understand. The factor structure was later verified using Confirmatory Factor Analysis (CFA) on 22 randomly selected open source projects meeting a predetermined eligibility criteria. Results: 24 code quality metrics that correspond to six constructs: Cohesion, In-Coupling, Out-Coupling, Size, Sub-Inheritance (related to subclasses), and Sup-Inheritance (related to superclasses) were revealed in the underlying factor structure. Ten metrics did not correspond to any known dimension of software quality and were removed in the EFA. Ten additional metrics exhibited low loadings in the CFA, suggesting their removal from the final measurement model. Size, Cohesion, Inheritance, and Coupling were the constructs retained, with subcategories identified for Inheritance and Coupling. Conclusions: Our results strongly support the construct validity of 24 code quality metrics. Coupling and Inheritance are revealed as multidimensional constructs, since they require measuring two different concepts, revealed as sub-categories in our analysis, and Complexity may be better explored in a multilevel model. Overall, our study demonstrates the value of applying modern measurement theory and latent variable modeling in validating software code quality metrics.