Does the Introduction of Lambda Expressions Improve the Comprehension of Java Programs?
Resumo
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.
Referências
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. https://books.google.de/books?id=JQg9jdrq26wC
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. https://books.google.de/books?id=LUGd6B9eyc4C
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. https://doi.org/10.1109/ICPC.2019.00014
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. https://doi.org/10.1145/3106237.3106264
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. https://doi.org/10.1145/2491411.2491461
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. https://doi.org/10.1109/ICSE.2019.00072
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. https://doi.org/10.1145/3133909
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. https://doi.org/10.1145/1640089.1640127
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. https://doi.org/10.1145/1985441.1985446
Nancy Pennington. 1987. Stimulus structures and mental representations in expert comprehension of computer programs. Cognitive Psychology 19, 3 (1987), 295--341. https://doi.org/10.1016/0010-0285(87)90007-7
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. https://doi.org/10.1145/2593882.2593893
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. https://doi.org/10.1109/ESEM.2009.5314233
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. https://doi.org/10.1109/ICPC.2016.7503707
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. https://doi.org/10.1109/WPC.1996.501117
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. https://doi.org/10.1109/ICSE.2017.14
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.