Link:http://refactoring.info/tools/LambdaFicator/

Problem Description

Java 8 will support lambda expressions and will extend the Collections APIs with functional operations like map or filter that apply a lambda expression over the elements of a collection. Refactoring existing code to use these new extensions enables explicit but unobtrusive parallelism and makes the code more succinct. However, refactoring is tedious (it requires changing many lines of code) and error-prone (the programmer must reason about the control-flow, data-flow, and side-effects). Fortunately, these refactorings can be automated. We present 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. In 9 open-source projects we have applied these two refactorings 1263 and 1709 times, respectively. The results show that LAMBDAFICATOR is useful. First, 55% of anonymous inner classes and 42% of for loops pass the preconditions, thus the refactorings are widely applicable. Second, converting anonymous to lambda decreases the code size by 2213 lines while converting for loops expressed 2382 operations, thus the refactorings provide real value to the projects. Third, the tool saved the programmer from changing 16020 lines, thus it reduces the programmer's burden.

Here is a cool YouTube demo of some features.

Use Lambdaficator

LAMBDAFICATOR is implemented as a NetBeans refactoring plugin. The tool provides two main workflow options, a QuickHint option and a batch option. The quick hint option scans the file that is open in the editor in real-time. If LAMBDAFICATOR finds a valid conversion, it underlines the code and displays a hint in the sidebar indicating this annonymous inner class can be converted into a lambda expression. If the programmer clicks the hint indicator, LAMBDAFICATOR applies the refactoring. This option allows the programmer to perform the refactoring without deviating from her normal workflow. The batch option allows the programmer to invoke the refactoring automatically by selecting any file, folder, or project open in the IDE. LAMBDAFICATOR can automatically apply the refactoring on all files or optionally generate a preview which lists the valid conversions and provides finegrain control over which conversions should take place. With the batch option, LAMBDAFICATOR can discover and apply hundreds of conversions in a matter of seconds. LAMBDAFICATOR is available in the JDK8-lambda branch of NetBeans. Instructions to get and build the JDK8-lambda branch of NetBeans are found here. In order to be able to run any of the refactorings you will need to install the lambda branch of JDK8

Below is a screenshot of running the AnonymousToLambda refactoring in batch mode, identifying an anonymous inner class that can be refactored to a lambda expression.

Below is a screenshot of applying the ForLoopToFunctional refactoring in batch mode and identifying one loop that can be refactored to three operations on collections using lambda expressions.

【转】LAMBDAFICATOR: Crossing the gap from imperative to functional programming through refactorings的更多相关文章

  1. paper 118:计算机视觉、模式识别、机器学习常用牛人主页链接

    牛人主页(主页有很多论文代码) Serge Belongie at UC San Diego Antonio Torralba at MIT Alexei Ffros at CMU Ce Liu at ...

  2. CVPR 2013 录用论文【待更新】

    完整录用论文官方链接:http://www.pamitc.org/cvpr13/program.php 过段时间CvPaper上面应该会有正文链接 今年有关RGB-D摄像机应用和研究的论文渐多起来了. ...

  3. What every computer science major should know 每一个计算机科学专业的毕业生都应该都知道的

    Given the expansive growth in the field, it's become challenging to discern what belongs in a modern ...

  4. DotNet 资源大全中文版(Awesome最新版)

    Awesome系列的.Net资源整理.awesome-dotnet是由quozd发起和维护.内容包括:编译器.压缩.应用框架.应用模板.加密.数据库.反编译.IDE.日志.风格指南等. 算法与数据结构 ...

  5. Introduction of python

    "Life is short, you need Python!" Python (British pronunciation:/ˈpaɪθən/ American pronunc ...

  6. 行为驱动开发iOS <收藏>

    前段时间在design+code购买了一个学习iOS设计和编码在线课程,使用Sketch设计App,然后使用Swift语言实现Designer News客户端.作者Meng To已经开源到Github ...

  7. F#之旅2 - 我有特别的学F#技巧

    原文地址:https://swlaschin.gitbooks.io/fsharpforfunandprofit/content/learning-fsharp/ Learning F#Functio ...

  8. a primary example for Functional programming in javascript

    background In pursuit of a real-world application, let’s say we need an e-commerce web applicationfo ...

  9. Java性能提示(全)

    http://www.onjava.com/pub/a/onjava/2001/05/30/optimization.htmlComparing the performance of LinkedLi ...

随机推荐

  1. dokuwiki安装问题

    工作了几年,虽然在程序员这个道路上才算开始,希望以后能够有所成长,为了把平时遇到的技术问题,记录下来,第一个想到的就是写wiki,博客虽然创建了许久,但是没有坚持写下去,在网上找了许多的wiki程序, ...

  2. Project2--Lucene的Ranking算法修改:BM25算法

    原文出自:http://blog.csdn.net/wbia2010lkl/article/details/6046661 1.       BM25算法 BM25是二元独立模型的扩展,其得分函数有很 ...

  3. 【bzoj2460】[BeiJing2011]元素

    2460: [BeiJing2011]元素 Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 692  Solved: 372[Submit][Statu ...

  4. c++原型模式(Prototype)

    原型模式是通过已经存在的对象的接口快速方便的创建新的对象. #include <iostream> #include <string> using namespace std; ...

  5. ByteUnit

    JDK里面有TimeUnit,看spark源码有个ByteUnit.这个类还是挺不错的. public enum ByteUnit { BYTE (1), KiB (1024L), MiB ((lon ...

  6. cbv+resful+APIView源码分析

    CBV源码分析 1概念:什么是cbv和fbv 已经什么是API class bass View ---基于类的视图 function bass View ---基于函数的视图 API(Applicat ...

  7. (转)使用Jquery+EasyUI进行框架项目开发案例讲解之一---员工管理源码分享

    原文地址:http://www.cnblogs.com/huyong/archive/2013/09/24/3334848.html 使用Jquery+EasyUI 进行框架项目开发案例讲解之一 员工 ...

  8. 20169219 NMap+Wireshark实验报告

    Tcpdump介绍 用简单的话来定义tcpdump,就是:dump the traffic on a network,根据使用者的定义对网络上的数据包进行截获的包分析工具. tcpdump可以将网络中 ...

  9. ORACLE_ERP帐务分录

      ORACLE MRPII各模块会计分录   第一章 采购模块 一.资产采购(科目来源:库存组织) 1.物料接收 借  材料采购     接收数量*采购单价 贷 应计暂估     接收数量*采购单价 ...

  10. SharePoint 2013在浏览器中打开pdf文档

    在没有安装Office Web Apps的情况下,SharePoint 2013是支持在IE上直接打开pdf和Excel文档的(只能查看,不能编辑,部分Excel会报错). 当然,需要现在管理中心做一 ...