Comparing the understandability of iteration mechanisms over Collections in Java

Author:

Hnatkowska Bogumiła1,Krych Bartosz1

Affiliation:

1. 1 Wroclaw University of Science and Technology , Wybrzeże Wyspiańskiego 27, 50-370 Wrocław , Poland

Abstract

Abstract Source code understandability is a desirable quality factor affecting long-term code maintenance. Understandability of source code can be assessed in a variety of ways, including subjective evaluation of code fragments (perceived understandability), correctness, and response time to tasks performed. It can also be assessed using various source code metrics, such as cyclomatic complexity or cognitive complexity. Programming languages are evolving, giving programmers new ways to do the same things, e.g., iterating over collections. Functional solutions (lambda expressions and streams) are added to typical imperative constructs like iterators or for-each statements. This research aims to check if there is a correlation between perceived understandability, understandability measured by task correctness, and predicted by source code metrics for typical tasks that require iteration over collections implemented in Java. The answer is based on the results of an experiment. The experiment involved 99 participants of varying ages, declared Java knowledge and seniority measured in years. Functional code was perceived as the most understandable, but only in one case, the subjective assessment was confirmed by the correctness of answers. In two examples with the highest perceived understandability, streams received the worst correctness scores. Cognitive complexity and McCabe’s complexity had the lowest values in all tasks for the functional approach, but – unfortunately – they did not correlate with answer correctness. The main finding is that the functional approach to collection manipulation is the best choice for the filter-map-reduce idiom and its alternatives (e.g., filter-only). It should not be used in more complex tasks, especially those with higher complexity metrics.

Publisher

Walter de Gruyter GmbH

Reference16 articles.

1. Baron, M. M., Wirich, M., Wagner, S.: An Empirical Validation of Cognitive Complexity as a Measure of Source Code Understandability, in Proceedings of the 14th ACM/IEEE International Symposium of Empirical Software Engineering and Measurement, p. 1-12, (2020).

2. Bexell, A.: Comparing functional to imperative Java with regards to readability, complexity, and verbosity, Växjö, (2017).

3. Cheon, Y., Escobar De La Torre, A.: Impacts of Java Language Features on the Memory Performances of Android Apps, ScholarWorks@UTEP, Impacts of Java Language Features on the Memory Performances of Android Apps - CORE (2017).

4. Costa, D. E., Andrzejak, A., Seboek, J, Lo, D.: Empirical Study of Usage and Performance of Java Collections, Proceedings of the 8th ACM/SPEC on International Conference on Performance Engineering, (2017).

5. Flauzino, M., Veríssimo, J., Terra, R., Cirilo, E., Durelli, V., Durelli, R.: Are you still smelling it?: A comparative study between Java and Kotlin Language, Proceedings of the VII Brazilian Symposium on Software Components, Architectures, and Reuse, pp. 23-32, (2018).

同舟云学术

1.学者识别学者识别

2.学术分析学术分析

3.人才评估人才评估

"同舟云学术"是以全球学者为主线,采集、加工和组织学术论文而形成的新型学术文献查询和分析系统,可以对全球学者进行文献检索和人才价值评估。用户可以通过关注某些学科领域的顶尖人物而持续追踪该领域的学科进展和研究前沿。经过近期的数据扩容,当前同舟云学术共收录了国内外主流学术期刊6万余种,收集的期刊论文及会议论文总量共计约1.5亿篇,并以每天添加12000余篇中外论文的速度递增。我们也可以为用户提供个性化、定制化的学者数据。欢迎来电咨询!咨询电话:010-8811{复制后删除}0370

www.globalauthorid.com

TOP

Copyright © 2019-2024 北京同舟云网络信息技术有限公司
京公网安备11010802033243号  京ICP备18003416号-3