Early Career Developers’ Perceptions of Code Understandability: A Study of Complexity Metrics

Context: Code understandability is crucial for developers, who continually modify the code to achieve changing business needs over time. Low understandability is associated with a significant increase in coding efforts and defect-proneness. To help assess code understandability, developers often use...

Full description

Saved in:
Bibliographic Details
Main Authors: Matteo Esposito, Andrea Janes, Terhi Kilamo, Valentina Lenarduzzi
Format: Article
Language:English
Published: IEEE 2025-01-01
Series:IEEE Access
Subjects:
Online Access:https://ieeexplore.ieee.org/document/11071285/
Tags: Add Tag
No Tags, Be the first to tag this record!
Description
Summary:Context: Code understandability is crucial for developers, who continually modify the code to achieve changing business needs over time. Low understandability is associated with a significant increase in coding efforts and defect-proneness. To help assess code understandability, developers often use complexity metrics. Objectives: Our work investigates the predictive power of code understandability of two metrics: The first is the well-known cyclomatic complexity metric. In contrast, the second one is the recently introduced cognitive complexity metric by SonarQube. Moreover, we also distinguish the predictions of understandability in general and the severity of issues in particular. Methods: We designed and conducted an empirical study with 216 early career developers with professional experience ranging from one to four years. We asked them to manually inspect and rate the understandability of 12 Java classes that exhibit different levels of Cyclomatic and Cognitive Complexity. Results: Our findings show that the two complexity metrics are modest predictors of code understandability. Particularly, when controlling the sizes of classes, the predictive power of McCabe complexity drops substantially, while the same is noticeable for cognitive complexity. Furthermore, the two metrics have no predictive power for the severity of issues. We also discuss particular cases and provide qualitative insights into these observations. Conclusions: We concluded that low complexity values indicate good understandability, but high values do not necessarily show low understandability. We found no evidence that the measures can predict severity at all. Furthermore, we provided explanations of understandability and seriousness in light of both developers’ comments and the metric values.
ISSN:2169-3536