Crossing the gap from imperative to functional programming through refactoring

Crossing the gap from imperative to functional programming through refactoring
复制标题

DOI:
10.1145/2491411.2491461
复制
发表时间:
2013-08
期刊:
--
影响因子:
--
通讯作者:
A. Gyori;Lyle Franklin;Danny Dig;J. Lahoda
A. Gyori;Lyle Franklin;Danny Dig;J. Lahoda
中科院分区:
其他
文献类型:
--
作者:
A. Gyori;Lyle Franklin;Danny Dig;J. Lahoda

文献摘要

被引文献

相似文献

Java 8引入了两个函数特性:lambda表达式和函数操作,如map或filter,它们将lambda表达式应用于Collection的元素。通过重构现有代码来使用这些新特性,可以实现显式但不显眼的并行性,并使代码更加简洁。然而,重构是乏味的:它需要更改许多行代码。它也容易出错:程序员必须对控制流、数据流和副作用进行推理。幸运的是,重构是可以自动化的。我们设计并实现了LambdaFicator,一个自动化两个重构的工具。第一个重构将匿名内部类转换为lambda表达式。第二个重构将遍历集合的for循环转换为使用lambda表达式的函数操作。在9个开源项目中,我们分别应用了这两种重构1263次和1709次。结果表明,LambdaFicator是有用的:(i)它适用广泛,(ii)它减少了代码膨胀,(iii)它提高了程序员的生产力,(iv)它是准确的。
Java 8 introduces two functional features: lambda expressions and functional operations like map or filter that apply a lambda expression over the elements of a Collection. Refactoring existing code to use these new features enables explicit but unobtrusive parallelism and makes the code more succinct. However, refactoring is tedious: it requires changing many lines of code. It is also error-prone: the programmer must reason about the control-, data-flow, and side-effects. Fortunately, refactorings can be automated. We designed and implemented LambdaFicator, a tool which automates two refactorings. The first refactoring converts anonymous inner classes to lambda expressions. The second refactoring converts for loops that iterate over Collections to functional operations that use lambda expressions. Using 9 open-source projects, we have applied these two refactorings 1263 and 1709 times, respectively. The results show that LambdaFicator is useful: (i) it is widely applicable, (ii) it reduces the code bloat, (iii) it increases programmer productivity, and (iv) it is accurate.