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. UIAtlas

    [UIAtlas] UIAtlas is a container that has coordinate information for a bunch of sprites. AtlasType有2 ...

  2. Codeforces 1142D Foreigner (DP)

    题意:首先定义了一种类数(标志数) 1:1到9都是标志数. 2:若x / 10是标志数,假设x /10在标志数中的排名是k, 若x的个位数小于k % 11, 那么x也是标志数. 现在给你一个字符串,问 ...

  3. mybatis 框架 的应用之二(批量添加、实现分页查询)

    lf-driver=com.mysql.jdbc.Driver lf-url=jdbc:mysql://localhost:3306/test lf-user=LF lf-password=LF &l ...

  4. Net-tools

    一.简介 Net-tools 包含如下程序,构成了 Linux 网络的基础. arp用来操作核心的ARP(地址解析协议)的高速缓存,通常用来增加.删除一个条目以及转储ARP高速缓存. dnsdomai ...

  5. vue.js的一些模板指令简述

    1.模板指令都是写在<template></template>html里面   v-text : value是什么就显示什么,如果value里面有html的标签,也会直接显示出 ...

  6. Linux安装tomcat服务器

    1.下载tomcat(区分windows和Linux,以tar.gz为后缀名的是Linux操作系统使用的). 官网下载地址:http://test.m.xiaoyuanhao.com/micro/ap ...

  7. swing中的分层

    swing中的分层 摘自:https://blog.csdn.net/levelmini/article/details/26692205 2014年05月23日 12:42:56 阅读数:1244 ...

  8. [GO]给导入包起别名

    package main import io "fmt" //引用fmt这个包时,名字重命名为io import _ "os" //引用os这个包,但是不调用, ...

  9. (转)Web API 强势入门指南

    原文地址:http://www.cnblogs.com/developersupport/p/aspnet-webapi.html Web API是一个比较宽泛的概念.这里我们提到Web API特指A ...

  10. MySQL性能调优与架构设计——第4章 MySQL安全管理

    第4章 MySQL安全管理 前言 对于任何一个企业来说,其数据库系统中所保存数据的安全性无疑是非常重要的,尤其是公司的有些商业数据,可能数据就是公司的根本,失去了数据的安全性,可能就是失去了公司的一切 ...