Comparing the understandability of iteration mechanisms over Collections in Java

IF 1.8 Q3 COMPUTER SCIENCE, ARTIFICIAL INTELLIGENCE
B. Hnatkowska, Bartosz Krych
{"title":"Comparing the understandability of iteration mechanisms over Collections in Java","authors":"B. Hnatkowska, Bartosz Krych","doi":"10.2478/fcds-2023-0002","DOIUrl":null,"url":null,"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.","PeriodicalId":42909,"journal":{"name":"Foundations of Computing and Decision Sciences","volume":"48 1","pages":"19 - 37"},"PeriodicalIF":1.8000,"publicationDate":"2023-03-01","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Foundations of Computing and Decision Sciences","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.2478/fcds-2023-0002","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"Q3","JCRName":"COMPUTER SCIENCE, ARTIFICIAL INTELLIGENCE","Score":null,"Total":0}
引用次数: 0

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.
比较Java中集合迭代机制的可理解性
摘要源代码的可理解性是影响长期代码维护的理想质量因素。源代码的可理解性可以通过多种方式进行评估,包括对代码片段(感知的可理解性)、正确性和执行任务的响应时间的主观评估。还可以使用各种源代码度量来评估它,例如圈复杂度或认知复杂度。编程语言在不断发展,为程序员提供了做同样事情的新方法,例如,遍历集合。函数式解决方案(lambda表达式和流)被添加到典型的命令式结构中,如迭代器或for-each语句。这项研究的目的是检查感知的可理解性、由任务正确性度量的可理解性,以及需要对Java实现的集合进行迭代的典型任务的源代码度量所预测的可理解性之间是否存在相关性。答案是基于一项实验的结果。实验涉及99名不同年龄的参与者,他们的Java知识和年资都不同。功能代码被认为是最容易理解的,但只有在一种情况下,主观评价被答案的正确性所证实。在两个可理解性最高的例子中,流的正确性得分最低。认知复杂性和McCabe的复杂性在功能方法的所有任务中都是最低的,但不幸的是,它们与答案的正确性没有关联。主要发现是,对于filter-map-reduce习语及其替代品(例如,filter-only)来说,集合操作的函数式方法是最佳选择。它不应该用于更复杂的任务,特别是那些具有更高复杂性指标的任务。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
Foundations of Computing and Decision Sciences
Foundations of Computing and Decision Sciences COMPUTER SCIENCE, ARTIFICIAL INTELLIGENCE-
CiteScore
2.20
自引率
9.10%
发文量
16
审稿时长
29 weeks
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术官方微信