Does the Introduction of Lambda Expressions Improve the Comprehension of Java Programs?

  • Walter Lucas UnB
  • Rodrigo Bonifácio UnB
  • Edna Dias Canedo UnB
  • Diego Marcílio UnB
  • Fernanda Lima


Background: The Java programming language version eighth introduced a number of features that encourage the functional style of programming, including the support for lambda expressions and the Stream API. Currently, there is a common wisdom that refactoring a legacy code to introduce lambda expressions, besides other potential benefits, simplifies the code and improves program comprehension. Aims: The purpose of this paper 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. First, we quantitatively analyze 66 pairs of real code snippets, where each pair corresponds to the body of a method before and after the introduction of lambda expressions. We computed two metrics related to source code complexity (number of lines of code and cyclomatic complexity) and two metrics that estimate the readability of the source code. Second, we conduct a survey with practitioners to collect their perceptions about the benefits on program comprehension, with the introduction of lambda expressions. The practitioners evaluate a number between three and six pairs of code snippets, to answer questions about possible improvements. Results: We found contradictory results in our research. Based on the quantitative assessment, we could not find evidences that the introduction of lambda expressions improves software readability--one of the components of program comprehension. Differently, our findings of the qualitative assessment suggest that the introduction of lambda expression improves program comprehension. 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 by lambda expressions). In addition, the opinion of the participants shine the opportunities in which a transformation for introducing lambda might be advantageous. This might support the implementation of effective tools for automatic program transformations. Finally, our results suggest that state-of-the-art models for estimating program readability are not helpful to capture the benefits of a program transformation to introduce lambda expressions.

Palavras-chave: Program Comprehension, Java Lambda Expressions, Empirical Studies


Anwar Alqaimi, Patanamon Thongtanunam, and Christoph Treude. 2019. Automatically Generating Documentation for Lambda Expressions in Java. In Proceedings of the 16th International Conference on Mining Software Repositories (MSR '19). IEEE Press, Piscataway, NJ, USA, 310--320. 00057

Robert Baggen, José Pedro Correia, Katrin Schill, and Joost Visser. 2012. Standardized code quality benchmarking for improving software maintainability. Software Quality Journal 20, 2 (01 Jun 2012), 287--307.

M. Borenstein, L.V. Hedges, J.P.T. Higgins, and H.R. Rothstein. 2011. Introduction to Meta-Analysis. Wiley.

Raymond P. L. Buse and Westley Weimer. 2010. Automatically documenting program changes. In ASE 2010, 25th IEEE/ACM International Conference on Automated Software Engineering, Antwerp, Belgium, September 20-24, 2010, Charles Pecheur, Jamie Andrews, and Elisabetta Di Nitto (Eds.). ACM, 33--42.

H. Cooper, L.V. Hedges, and J.C. Valentine. 2009. The Handbook of Research Synthesis and Meta-Analysis. Russell Sage Foundation.

Reno Dantas, Antonio Carvalho, Diego Marcilio, Luisa Fantin, Uriel Silva, Walter Lucas, and Rodrigo Bonifácio. 2018. Reconciling the past and the present: An empirical study on the application of source code transformations to automatically rejuvenate Java programs. In 25th International Conference on Software Analysis, Evolution and Reengineering, SANER 2018, Campobasso, Italy, March 20-23, 2018, Rocco Oliveto, Massimiliano Di Penta, and David C. Shepherd (Eds.). IEEE Computer Society, 497--501.

Rodrigo Magalhães dos Santos and Marco Aurélio Gerosa. 2018. Impacts of coding practices on readability. In Proceedings of the 26th Conference on Program Comprehension, ICPC 2018, Gothenburg, Sweden, May 27-28, 2018, Foutse Khomh, Chanchal K. Roy, and Janet Siegmund (Eds.). ACM, 277--285.

Sarah Fakhoury, Devjeet Roy, Sk. Adnan Hassan, and Venera Arnaoudova. 2019. Improving Source Code Readability: Theory and Practice. In Proceedings of the 27th International Conference on Program Comprehension (ICPC '19). IEEE Press, Piscataway, NJ, USA, 2--12.

Jean-Marie Favre, Ralf Lämmel, Thomas Schmorleiz, and Andrei Varanovich. 2012. 101companies: A Community Project on Software Technologies and Software Languages. In Objects, Models, Components, Patterns, Carlo A. Furia and Sebastian Nanz (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 58--74.

Dan Gopstein, Jake Iannacone, Yu Yan, Lois DeLong, Yanyan Zhuang, Martin K.-C. Yeh, and Justin Cappos. 2017. Understanding Misunderstandings in Source Code. In Proceedings of the 2017 11th Joint Meeting on Foundations of Software Engineering (ESEC/FSE 2017). ACM, New York, NY, USA, 129--139.

Alex Gyori, Lyle Franklin, Danny Dig, and Jan Lahoda. 2013. Crossing the Gap from Imperative to Functional Programming Through Refactoring. In Proceedings of the 2013 9th Joint Meeting on Foundations of Software Engineering (ESEC/FSE 2013). ACM, New York, NY, USA, 543--553.

Raffi Khatchadourian, Yiming Tang, Mehdi Bagherzadeh, and Syed Ahmed. 2019. Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams. In Proceedings of the 41st International Conference on Software Engineering (ICSE '19). IEEE Press, Piscataway, NJ, USA, 619--630.

Davy Landman, Alexander Serebrenik, Eric Bouwers, and Jurgen J. Vinju. 2016. Empirical analysis of the relationship between CC and SLOC in a large corpus of Java methods and C functions. Journal of Software: Evolution and Process 28, 7 (2016), 589--618.

Davood Mazinanian, Ameya Ketkar, Nikolaos Tsantalis, and Danny Dig. 2017. Understanding the Use of Lambda Expressions in Java. Proc. ACM Program. Lang. 1, OOPSLA, Article 85 (Oct. 2017), 31 pages.

Jeffrey L. Overbey and Ralph E. Johnson. 2009. Regrowing a Language: Refactoring Tools Allow Programming Languages to Evolve. In Proceedings of the 24th ACM SIGPLAN Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA '09). ACM, New York, NY, USA, 493--502.

Chris Parnin, Christian Bird, and Emerson R. Murphy-Hill. 2011. Java generics adoption: how new features are introduced, championed, or ignored. In Proceedings of the 8th International Working Conference on Mining Software Repositories, MSR 2011 (Co-located with ICSE), Waikiki, Honolulu, HI, USA, May 21-28, 2011, Proceedings, Arie van Deursen, Tao Xie, and Thomas Zimmermann (Eds.). ACM, 3--12.

Nancy Pennington. 1987. Stimulus structures and mental representations in expert comprehension of computer programs. Cognitive Psychology 19, 3 (1987), 295--341.

Daryl Posnett, Abram Hindle, and Premkumar T. Devanbu. 2011. A simpler model of software readability. In Proceedings of the 8th International Working Conference on Mining Software Repositories, MSR 2011 (Co-located with ICSE), Waikiki, Honolulu, HI, USA, May 21-28, 2011, Proceedings, Arie van Deursen, Tao Xie, and Thomas Zimmermann (Eds.). ACM, 73--82.

Václav Rajlich. 2014. Software Evolution and Maintenance. In Proceedings of the on Future of Software Engineering (FOSE 2014). ACM, New York, NY, USA, 133--144.

M. Riaz, E. Mendes, and E. Tempero. 2009. A systematic review of software maintainability prediction and metrics. In 2009 3rd International Symposium on Empirical Software Engineering and Measurement. 367--377.

S. Scalabrino, M. Linares-Vásquez, D. Poshyvanyk, and R. Oliveto. 2016. Improving code readability models with textual features. In 2016 IEEE 24th International Conference on Program Comprehension (ICPC). 1--10.

Margaret-Anne D. Storey, Kenny Wong, and Hausi A. Müller. 2000. How do program understanding tools affect how programmers understand programs? Sci. Comput. Program. 36, 2-3 (2000), 183--207.

S. R. Tilley, S. Paul, and D. B. Smith. 1996. Towards a framework for program understanding. In WPC '96. 4th Workshop on Program Comprehension. 19--28.

N. Tsantalis, D. Mazinanian, and S. Rostami. 2017. Clone Refactoring with Lambda Expressions. In 2017 IEEE/ACM 39th International Conference on Software Engineering(ICSE). 60--70.

Anneliese von Mayrhauser and A. Marie Vans. 1995. Program Comprehension During Software Maintenance and Evolution. IEEE Computer 28, 8 (1995), 44--55.

Frank Wilcoxon. 1945. Individual Comparisons by Ranking Methods. Biometrics Bulletin (JSTOR) 1, 6 (1945), 80--83.
Como Citar

Selecione um Formato
LUCAS, Walter; BONIFÁCIO, Rodrigo; CANEDO, Edna Dias; MARCÍLIO, Diego; LIMA, Fernanda. Does the Introduction of Lambda Expressions Improve the Comprehension of Java Programs?. In: SIMPÓSIO BRASILEIRO DE ENGENHARIA DE SOFTWARE (SBES), 33. , 2019, Salvador. Anais [...]. Porto Alegre: Sociedade Brasileira de Computação, 2019 .