Understanding the Impact of Introducing Lambda Expressions in Java Programs

Walter Lucas Monteiro de Mendonça, José Fortes, Francisco Vitor Lopes, Diego Marcilio, R. Bonifácio, E. Canedo, Fernanda Lima, J. Saraiva
{"title":"Understanding the Impact of Introducing Lambda Expressions in Java Programs","authors":"Walter Lucas Monteiro de Mendonça, José Fortes, Francisco Vitor Lopes, Diego Marcilio, R. Bonifácio, E. Canedo, Fernanda Lima, J. Saraiva","doi":"10.5753/JSERD.2020.744","DOIUrl":null,"url":null,"abstract":"Background: The Java programming language version eight introduced several features that encourage the functional style of programming, including the support for lambda expressions and the Stream API. Currently, there is common wisdom that refactoring legacy code to introduce lambda expressions, besides other potential benefits, simplifies the code and improves program comprehension. Aims: The purpose of this work is to investigate this belief, conducting an in-depth study to evaluate the effect of introducing lambda expressions on program comprehension. Method: We conduct this research using a mixed-method study. For the quantitative method, we quantitatively analyze 166 pairs of code snippets extracted directly either from GitHub or from recommendations from three tools (RJTL, NetBeans, and IntelliJ). We also surveyed practitioners to collect their perceptions about the benefits on program comprehension when introducing lambda expressions. We asked practitioners to evaluate and rate sets of pairs of code snippets. Results: We found contradictory results in our research. Based on the quantitative assessment, we could not find evidence that the introduction of lambda expressions improves software readability—one of the components of program comprehension. Our results suggest that the transformations recommended by the aforementioned tools decrease program comprehension when assessed by two state-of-the-art models to estimate readability. Differently, our findings of the qualitative assessment suggest that the introduction of lambda expression improves program comprehension in three scenarios: when we convert anonymous inner classes to a lambda expression, structural loops with inner conditional to a anyMatch operator, and structural loops to filter operator combined with a collect method. Implications: We argue in this paper that one can improve program comprehension when she applies particular transformations to introduce lambda expressions (e.g., replacing anonymous inner classes with lambda expressions). Also, the opinion of the participants shines the opportunities in which a transformation for introducing lambda might be advantageous. This might support the implementation of effective tools for automatic program transformations.","PeriodicalId":189472,"journal":{"name":"J. Softw. Eng. Res. Dev.","volume":"141 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2020-10-11","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"4","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"J. Softw. Eng. Res. Dev.","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.5753/JSERD.2020.744","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 4

Abstract

Background: The Java programming language version eight introduced several features that encourage the functional style of programming, including the support for lambda expressions and the Stream API. Currently, there is common wisdom that refactoring legacy code to introduce lambda expressions, besides other potential benefits, simplifies the code and improves program comprehension. Aims: The purpose of this work is to investigate this belief, conducting an in-depth study to evaluate the effect of introducing lambda expressions on program comprehension. Method: We conduct this research using a mixed-method study. For the quantitative method, we quantitatively analyze 166 pairs of code snippets extracted directly either from GitHub or from recommendations from three tools (RJTL, NetBeans, and IntelliJ). We also surveyed practitioners to collect their perceptions about the benefits on program comprehension when introducing lambda expressions. We asked practitioners to evaluate and rate sets of pairs of code snippets. Results: We found contradictory results in our research. Based on the quantitative assessment, we could not find evidence that the introduction of lambda expressions improves software readability—one of the components of program comprehension. Our results suggest that the transformations recommended by the aforementioned tools decrease program comprehension when assessed by two state-of-the-art models to estimate readability. Differently, our findings of the qualitative assessment suggest that the introduction of lambda expression improves program comprehension in three scenarios: when we convert anonymous inner classes to a lambda expression, structural loops with inner conditional to a anyMatch operator, and structural loops to filter operator combined with a collect method. Implications: We argue in this paper that one can improve program comprehension when she applies particular transformations to introduce lambda expressions (e.g., replacing anonymous inner classes with lambda expressions). Also, the opinion of the participants shines the opportunities in which a transformation for introducing lambda might be advantageous. This might support the implementation of effective tools for automatic program transformations.
理解在Java程序中引入Lambda表达式的影响
背景:Java编程语言版本8引入了几个鼓励函数式编程风格的特性,包括对lambda表达式和Stream API的支持。目前,人们普遍认为重构遗留代码以引入lambda表达式,除了其他潜在的好处之外,还可以简化代码并提高程序的可理解性。目的:这项工作的目的是调查这一信念,进行深入的研究,以评估引入lambda表达式对程序理解的影响。方法:采用混合方法进行研究。对于定量方法,我们定量分析了直接从GitHub或从三个工具(RJTL, NetBeans和IntelliJ)的推荐中提取的166对代码片段。我们还调查了从业人员,以收集他们对引入lambda表达式对程序理解的好处的看法。我们要求从业者评估和评价代码片段对的集合。结果:我们在研究中发现了相互矛盾的结果。基于定量评估,我们没有发现lambda表达式的引入提高软件可读性的证据——可读性是程序理解的组成部分之一。我们的结果表明,当用两个最先进的模型来评估可读性时,上述工具推荐的转换会降低程序的理解能力。不同的是,我们的定性评估结果表明,lambda表达式的引入在三种情况下提高了程序的可理解性:当我们将匿名内部类转换为lambda表达式时,将带有内部条件的结构循环转换为anyMatch操作符,以及将结构循环转换为带有collect方法的过滤操作符。启示:我们在本文中认为,当应用特定的转换来引入lambda表达式(例如,用lambda表达式替换匿名内部类)时,可以提高程序的理解能力。此外,与会者的意见还指出了引入lambda的转换可能是有利的。这可能支持实现用于自动程序转换的有效工具。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
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学术文献互助群
群 号:604180095
Book学术官方微信