TY - GEN
T1 - An empirical validation of cognitive complexity as a measure of source code understandability
AU - Barón, Marvin Muñoz
AU - Wyrich, Marvin
AU - Wagner, Stefan
N1 - Publisher Copyright:
© 2020 IEEE Computer Society. All rights reserved.
PY - 2020/10/5
Y1 - 2020/10/5
N2 - 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 thiswork,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 wellknown 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.
AB - 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 thiswork,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 wellknown 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.
KW - Cognitive complexity
KW - Meta-analysis
KW - Software metrics
KW - Source code comprehension
KW - Source code understandability
UR - http://www.scopus.com/inward/record.url?scp=85095843161&partnerID=8YFLogxK
U2 - 10.1145/3382494.3410636
DO - 10.1145/3382494.3410636
M3 - Conference contribution
AN - SCOPUS:85095843161
T3 - International Symposium on Empirical Software Engineering and Measurement
BT - ESEM 2020 - Proceedings of the 14th ACM/IEEE International Symposium on Empirical Software Engineering and Measurement
PB - IEEE Computer Society
T2 - 14th ACM/IEEE International Symposium on Empirical Software Engineering and Measurement, ESEM 2020
Y2 - 5 October 2020 through 7 October 2020
ER -