An Empirical Validation of Cognitive Complexity as a Measure of Source Code Understandability

07/24/2020
by   Marvin Muñoz Barón, et al.
0

Background: Developers spend a lot of their time on understanding source code. Static code analysis tools can draw attention to code that is difficult for developers to understand. However, most of the findings are based on non-validated metrics, which can lead to confusion and code, that is hard to understand, not being identified. Aims: In this work, we validate a metric called Cognitive Complexity which was explicitly designed to measure code understandability and which is already widely used due to its integration in well-known static code analysis tools. Method: We conducted a systematic literature search to obtain data sets from studies which measured code understandability. This way we obtained about 24,000 understandability evaluations of 427 code snippets. We calculated the correlations of these measurements with the corresponding metric values and statistically summarized the correlation coefficients through a meta-analysis. Results: Cognitive Complexity positively correlates with comprehension time and subjective ratings of understandability. The metric showed mixed results for the correlation with the correctness of comprehension tasks and with physiological measures. Conclusions: It is the first validated and solely code-based metric which is able to reflect at least some aspects of code understandability. Moreover, due to its methodology, this work shows that code understanding is currently measured in many different ways, which we also do not know how they are related. This makes it difficult to compare the results of individual studies as well as to develop a metric that measures code understanding in all its facets.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
12/16/2020

The Mind Is a Powerful Place: How Showing Code Comprehensibility Metrics Influences Code Understanding

Static code analysis tools and integrated development environments prese...
research
09/28/2021

Code Comprehension Confounders: A Study of Intelligence and Personal

Literature and intuition suggest that a developer's intelligence and per...
research
08/20/2021

Readability and Understandability Scores for Snippet Assessment: an Exploratory Study

Code search engines usually use readability feature to rank code snippet...
research
03/08/2019

A Replication Study on Code Comprehension and Expertise using Lightweight Biometric Sensors

Code comprehension has been recently investigated from physiological and...
research
12/18/2018

Integrating Runtime Values with Source Code to Facilitate Program Comprehension

An inherently abstract nature of source code makes programs difficult to...
research
06/22/2022

40 Years of Designing Code Comprehension Experiments: A Systematic Mapping Study

The relevance of code comprehension in a developer's daily work was reco...

Please sign up or login with your details

Forgot password? Click here to reset