On the accuracy of code complexity metrics: A neuroscience-based guideline for improvement
Frontiers in Neuroscience · 07.02.2023 · 16
DOI: 10.3389/fnins.2022.1065366 ↗Kurz gefasst
Leitlinie in der Zeitschrift Frontiers in Neuroscience, online erschienen am 07.02.2023. Verfasst von Gao Hao und 10 weiteren Autor:innen. Beteiligte Einrichtung: Faculty of Applied Sciences, Macao Polytechnic University, Macao, Macao SAR, China. Die Arbeit wurde bisher 20-mal zitiert (Crossref) und nennt 59 Literaturangaben. Der Volltext ist frei zugänglich (Open Access, CC BY 4.0). Gefördert von: Fundação para a Ciência e a Tecnologia.
Abstract (Originalsprache)
Complexity is the key element of software quality. This article investigates the problem of measuring code complexity and discusses the results of a controlled experiment to compare different views and methods to measure code complexity. Participants (27 programmers) were asked to read and (try to) understand a set of programs, while the complexity of such programs is assessed through different methods and perspectives: (a) classic code complexity metrics such as McCabe and Halstead metrics, (b) cognitive complexity metrics based on scored code constructs, (c) cognitive complexity metrics from state-of-the-art tools such as SonarQube, (d) human-centered metrics relying on the direct assessment of programmers’ behavioral features (e.g., reading time, and revisits) using eye tracking, and (e) cognitive load/mental effort assessed using electroencephalography (EEG). The human-centered perspective was complemented by the subjective evaluation of participants on the mental effort required to understand the programs using the NASA Task Load Index (TLX). Additionally, the evaluation of the code complexity is measured at both the program level and, whenever possible, at the very low level of code constructs/code regions, to identify the actual code elements and the code context that may trigger a complexity surge in the programmers’ perception of code comprehension difficulty. The programmers’ cognitive load measured using EEG was used as a reference to evaluate how the different metrics can express the (human) difficulty in comprehending the code. Extensive experimental results show that popular metrics such as V(g) and the complexity metric from SonarSource tools deviate considerably from the programmers’ perception of code complexity and often do not show the expected monotonic behavior. The article summarizes the findings in a set of guidelines to improve existing code complexity metrics, particularly state-of-the-art metrics such as cognitive complexity from SonarSource tools.
Schlagwörter
Stichwörter der Autor:innen
Autor:innen und Institutionen
- Faculty of Applied Sciences, Macao Polytechnic University, Macao, Macao SAR, China.
- Center for Informatics and Systems of the University of Coimbra (CISUC), University of Coimbra, Coimbra, Portugal.
- Center for Informatics and Systems of the University of Coimbra (CISUC), Polytechnic Institute of Coimbra, Coimbra, Portugal.
- Institute of Nuclear Science Applied to Health (ICNAS)/Coimbra Institute for Biomedical Imaging and Translational Research (CIBIT), University of Coimbra, Coimbra, Portugal.
Förderung
- Fundação para a Ciência e a Tecnologia
Zitieren
APA
Hao, G., Hijazi, H., Durães, J., Medeiros, J., Couceiro, R., Lam, C. T., Teixeira, C., Castelhano, J., Castelo Branco, M., Carvalho, P., & Madeira, H. (2023). On the accuracy of code complexity metrics: A neuroscience-based guideline for improvement. Frontiers in Neuroscience, 16. https://doi.org/10.3389/fnins.2022.1065366
Vancouver
Hao G, Hijazi H, Durães J, Medeiros J, Couceiro R, Lam CT, et al. On the accuracy of code complexity metrics: A neuroscience-based guideline for improvement. Frontiers in Neuroscience. 2023;16. doi:10.3389/fnins.2022.1065366
BibTeX
@article{Hao2023,
author = {Hao, Gao and Hijazi, Haytham and Durães, João and Medeiros, Júlio and Couceiro, Ricardo and Lam, Chan Tong and Teixeira, César and Castelhano, João and Castelo Branco, Miguel and Carvalho, Paulo and Madeira, Henrique},
title = {On the accuracy of code complexity metrics: A neuroscience-based guideline for improvement},
journal = {Frontiers in Neuroscience},
year = {2023},
volume = {16},
doi = {10.3389/fnins.2022.1065366}
}
EUVIMED