SlideShare a Scribd company logo
1
Smart Migration
to JDK 8

2
Language Changes in Java 8
Themes
 From Imperative to Functional
– Use modern constructs other newer languages use.
– Enhance code readability.
– Strip out the boilerplate code.
– Stop telling the compiler what to do.

 From Sequential to Parallel
– Execute code in parallel without extra effort.
– Divide problems into subproblems

solve subproblems simultaneously
and combine the results.
– Aggregate operations instead of fork/join.
3
Language Changes in Java 8
From Imperative to Functional, From Sequential to Parallel
 Virtual extension methods
 Functional interfaces
 Lambdas
 Method references
 Streams

 Collections
 Time
 Concurrency
 IO/NIO
 Reflections and annotations
 Miscellaneous
4
Building Blocks of Java 8
From Imperative to Functional, From Sequential to Parallel
 Virtual extension methods
– Break existing code when adding a method to an interface?
– Java 8 allows to add new methods to interfaces.

– Revolutionary – interface evolution is now possible.
 Functional interfaces
– A functional interface

defines exactly one abstract method,
focused on one specific task.
– For example, java.lang.Runnable

defines one abstract method “run()”.
– @FunctionalInterface
5
Lambda
From Imperative to Functional, From Sequential to Parallel
 Remove boilerplate code of anonymous inner classes. Better syntax.

6
Demo

How to Migrate to
Lambdas

7
Functions
From Imperative to Functional, From Sequential to Parallel
 java.util.Function – defines new functional interfaces, in addition to EventHandler, etc.

8
Functions
From Imperative to Functional, From Sequential to Parallel
 java.util.Function – defines new functional interfaces, in addition to EventHandler, etc.

New Functional
Interfaces
Function<T,R>

BiFunction, ToIntFunction, LongToIntFunction, etc.

Predicate<T>

IntPredicate, LongPredicate, DoublePredicate, etc.

Consumer<T>

IntConsumer, DoubleConsumer, LongConsumer, etc.

Supplier<T>

IntSupplier, BinarySupplier, DoubleSupplier, etc.

BinaryOperator<T>

9

Many Primitive Specializations

IntBinaryOperator, IntUnaryOperator, etc.
Streams: Pipes & Filters
From Imperative to Functional, From Sequential to Parallel
 java.util.Stream – provides a pipeline with filters. Source is processed through a pipe.

 Each successive aggregate operation in the pipeline is one of:
– Intermediate – map, filter, sorted, distinct, limit, skip, substream
– Terminal – forEach, sum, collect, reduce, count, findFirst, findAny

 Lazy evaluation – process only as needed and as many times as needed, e.g., “findFirst”.
 No intermediate storage.
10
Streams: Classes & Methods
From Imperative to Functional, From Sequential to Parallel
IntStream

Builder

LongStream
DoubleStream

anyMatch

distinct
concat

noneMatch

empty

count
range

of

parallel
11

map
max

peek
allMatch

forEachOrder

findAny
flatMap

collect
min

findFirst

sequential

forEach
limit

iterate

reduce
skip
sorted
toArray
filter
builder

boxed

generate
Streams: Collections
From Imperative to Functional, From Sequential to Parallel
 Distinguish between “what should be done” and “how it should be done”.
 Collections APIs have been extended. Collections can be exposed as Streams.

 Identify and refactor “for” loops. Replace with internal iterations provided by Streams.
 That lets you express concurrent processing of elements in parallel.
12
13
Demo

How to Migrate to
Streams

14
Method Reference
From Imperative to Functional, From Sequential to Parallel
 Method references are an abbreviated style for expressing lambdas.
x -> String.valueOf(x)
x -> x.toString
() -> x.toString()
() -> new ArrayList()

/
/
/
/

String::valueOf
Object::toString
x::toString
ArrayList::new

 Where a method already exists to perform an operation,

a method reference can be used instead of a lambda.

15
Demo

How to Migrate to
Method References

16
Automation and Batch Processing
From Imperative to Functional, From Sequential to Parallel
 Refactoring tool scans across a scope – all projects, single project, single package, file...
 Find candidates for upgrading to lambdas, functional operations, and method references.

17
Demo

Automation and
Batch Processing

18
Getting Started
From Imperative to Functional, From Sequential to Parallel
 Download NetBeans IDE 8.
 Register JDK 8 in the IDE.

 Set JDK 8 on the project.
 Change Source Format to JDK 8.

19
Demo

Getting Started

20
Community Feedback
From Imperative to Functional, From Sequential to Parallel

21
Summary
From Imperative to Functional, From Sequential to Parallel
 Virtual extension methods and functional interfaces make lambdas possible.
 Lambdas remove boilerplate code of anonymous inner classes.
 Streams provide pipelines, filters, and parallelism to Collections.
 Method references are an alternative shorthand for lambdas.

22
Next Steps

23
References
From Imperative to Functional, From Sequential to Parallel
 http://cr.openjdk.java.net/~briangoetz/lambda/lambda-state-final.html

 http://blog.hartveld.com/2013/03/jdk-8-13-interface-default-method.html
 http://www.techempower.com/blog/2013/03/26/everything-about-java-8/
 http://technology.amis.nl/2013/10/05/java-8-collection-enhancements-leveraging-lambda-expressions-or-how-java-

emulates-sql/
 http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/Lambda-QuickStart/index.html
 http://drunkendev.blogspot.nl/2014/01/migrating-to-jdk-8-with-netbeans.html
 http://devoxx.com/display/DV12/Closures+and+Collections+-+the+World+After+Eight
 http://refactoring.info/tools/LambdaFicator/
24
25

More Related Content

What's hot

Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams
Ganesh Samarthyam
 
Java concurrency questions and answers
Java concurrency questions and answers Java concurrency questions and answers
Java concurrency questions and answers
CodeOps Technologies LLP
 
Introduction to Java 8
Introduction to Java 8Introduction to Java 8
Introduction to Java 8
Knoldus Inc.
 
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIModern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Ganesh Samarthyam
 
The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8
Takipi
 
JDK1.6
JDK1.6JDK1.6
JDK1.6
india_mani
 
Java 8 Features
Java 8 FeaturesJava 8 Features
Java 8 Features
Trung Nguyen
 
Core Java - Quiz Questions - Bug Hunt
Core Java - Quiz Questions - Bug HuntCore Java - Quiz Questions - Bug Hunt
Core Java - Quiz Questions - Bug Hunt
CodeOps Technologies LLP
 
55 New Features in Java SE 8
55 New Features in Java SE 855 New Features in Java SE 8
55 New Features in Java SE 8
Simon Ritter
 
Java SE 8 library design
Java SE 8 library designJava SE 8 library design
Java SE 8 library design
Stephen Colebourne
 
Java 7 & 8
Java 7 & 8Java 7 & 8
Java 7 & 8
Ken Coenen
 
JVM
JVMJVM
Lambda Expressions in Java 8
Lambda Expressions in Java 8Lambda Expressions in Java 8
Lambda Expressions in Java 8
icarter09
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
Nicola Pedot
 
New Features of JAVA SE8
New Features of JAVA SE8New Features of JAVA SE8
New Features of JAVA SE8
Dinesh Pathak
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Nayden Gochev
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014Nayden Gochev
 
모던자바의 역습
모던자바의 역습모던자바의 역습
모던자바의 역습
DoHyun Jung
 

What's hot (20)

Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams
 
Java 8 Features
Java 8 FeaturesJava 8 Features
Java 8 Features
 
Java concurrency questions and answers
Java concurrency questions and answers Java concurrency questions and answers
Java concurrency questions and answers
 
Introduction to Java 8
Introduction to Java 8Introduction to Java 8
Introduction to Java 8
 
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIModern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
 
The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8
 
JDK1.6
JDK1.6JDK1.6
JDK1.6
 
Java 8 Features
Java 8 FeaturesJava 8 Features
Java 8 Features
 
Core Java - Quiz Questions - Bug Hunt
Core Java - Quiz Questions - Bug HuntCore Java - Quiz Questions - Bug Hunt
Core Java - Quiz Questions - Bug Hunt
 
Java 7 New Features
Java 7 New FeaturesJava 7 New Features
Java 7 New Features
 
55 New Features in Java SE 8
55 New Features in Java SE 855 New Features in Java SE 8
55 New Features in Java SE 8
 
Java SE 8 library design
Java SE 8 library designJava SE 8 library design
Java SE 8 library design
 
Java 7 & 8
Java 7 & 8Java 7 & 8
Java 7 & 8
 
JVM
JVMJVM
JVM
 
Lambda Expressions in Java 8
Lambda Expressions in Java 8Lambda Expressions in Java 8
Lambda Expressions in Java 8
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
 
New Features of JAVA SE8
New Features of JAVA SE8New Features of JAVA SE8
New Features of JAVA SE8
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
 
모던자바의 역습
모던자바의 역습모던자바의 역습
모던자바의 역습
 

Viewers also liked

Spring Cloud in a Nutshell
Spring Cloud in a NutshellSpring Cloud in a Nutshell
Spring Cloud in a Nutshell
Tsuyoshi Miyake
 
Java 7 - State of the Enterprise
Java 7 - State of the EnterpriseJava 7 - State of the Enterprise
Java 7 - State of the Enterprise
Markus Eisele
 
Evolution of database access technologies in Java-based software projects
Evolution of database access technologies in Java-based software projectsEvolution of database access technologies in Java-based software projects
Evolution of database access technologies in Java-based software projects
Tom Mens
 
Oracle Database Appliance 2.8 アップデート及びパッチ管理について
Oracle Database Appliance 2.8 アップデート及びパッチ管理についてOracle Database Appliance 2.8 アップデート及びパッチ管理について
Oracle Database Appliance 2.8 アップデート及びパッチ管理について
オラクルエンジニア通信
 
Oracle Database Appliance 2.10 アップデート及びパッチ管理について
Oracle Database Appliance 2.10 アップデート及びパッチ管理について Oracle Database Appliance 2.10 アップデート及びパッチ管理について
Oracle Database Appliance 2.10 アップデート及びパッチ管理について
オラクルエンジニア通信
 
Oracle Database 12c R1 主要新機能のご紹介
Oracle Database 12c R1 主要新機能のご紹介Oracle Database 12c R1 主要新機能のご紹介
Oracle Database 12c R1 主要新機能のご紹介
オラクルエンジニア通信
 
Oracle Database Appliance 12.1.2.1.0 アップデート及びパッチ管理について
Oracle Database Appliance 12.1.2.1.0 アップデート及びパッチ管理について Oracle Database Appliance 12.1.2.1.0 アップデート及びパッチ管理について
Oracle Database Appliance 12.1.2.1.0 アップデート及びパッチ管理について
オラクルエンジニア通信
 
Oracle Database Appliance 12.1.2.2.0 アップデート及びパッチ管理について
Oracle Database Appliance 12.1.2.2.0 アップデート及びパッチ管理についてOracle Database Appliance 12.1.2.2.0 アップデート及びパッチ管理について
Oracle Database Appliance 12.1.2.2.0 アップデート及びパッチ管理について
オラクルエンジニア通信
 
新機能によるデータベースシステムの改善ポイント
新機能によるデータベースシステムの改善ポイント新機能によるデータベースシステムの改善ポイント
新機能によるデータベースシステムの改善ポイント
オラクルエンジニア通信
 
Oracle Database 12c Release 1 PSR 12.1.0.2 のご紹介
Oracle Database 12c Release 1 PSR 12.1.0.2 のご紹介Oracle Database 12c Release 1 PSR 12.1.0.2 のご紹介
Oracle Database 12c Release 1 PSR 12.1.0.2 のご紹介
オラクルエンジニア通信
 
Oracle Database Appliance 12.1.2.3.0 アップデート及びパッチ管理について
Oracle Database Appliance 12.1.2.3.0 アップデート及びパッチ管理についてOracle Database Appliance 12.1.2.3.0 アップデート及びパッチ管理について
Oracle Database Appliance 12.1.2.3.0 アップデート及びパッチ管理について
オラクルエンジニア通信
 
Oracle Database Enterprise Edition で解決する データベースシステムの課題 (12c対応版)
Oracle Database Enterprise Edition で解決するデータベースシステムの課題 (12c対応版)Oracle Database Enterprise Edition で解決するデータベースシステムの課題 (12c対応版)
Oracle Database Enterprise Edition で解決する データベースシステムの課題 (12c対応版)オラクルエンジニア通信
 
Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)
Trisha Gee
 
New Features in JDK 8
New Features in JDK 8New Features in JDK 8
New Features in JDK 8
Martin Toshev
 

Viewers also liked (14)

Spring Cloud in a Nutshell
Spring Cloud in a NutshellSpring Cloud in a Nutshell
Spring Cloud in a Nutshell
 
Java 7 - State of the Enterprise
Java 7 - State of the EnterpriseJava 7 - State of the Enterprise
Java 7 - State of the Enterprise
 
Evolution of database access technologies in Java-based software projects
Evolution of database access technologies in Java-based software projectsEvolution of database access technologies in Java-based software projects
Evolution of database access technologies in Java-based software projects
 
Oracle Database Appliance 2.8 アップデート及びパッチ管理について
Oracle Database Appliance 2.8 アップデート及びパッチ管理についてOracle Database Appliance 2.8 アップデート及びパッチ管理について
Oracle Database Appliance 2.8 アップデート及びパッチ管理について
 
Oracle Database Appliance 2.10 アップデート及びパッチ管理について
Oracle Database Appliance 2.10 アップデート及びパッチ管理について Oracle Database Appliance 2.10 アップデート及びパッチ管理について
Oracle Database Appliance 2.10 アップデート及びパッチ管理について
 
Oracle Database 12c R1 主要新機能のご紹介
Oracle Database 12c R1 主要新機能のご紹介Oracle Database 12c R1 主要新機能のご紹介
Oracle Database 12c R1 主要新機能のご紹介
 
Oracle Database Appliance 12.1.2.1.0 アップデート及びパッチ管理について
Oracle Database Appliance 12.1.2.1.0 アップデート及びパッチ管理について Oracle Database Appliance 12.1.2.1.0 アップデート及びパッチ管理について
Oracle Database Appliance 12.1.2.1.0 アップデート及びパッチ管理について
 
Oracle Database Appliance 12.1.2.2.0 アップデート及びパッチ管理について
Oracle Database Appliance 12.1.2.2.0 アップデート及びパッチ管理についてOracle Database Appliance 12.1.2.2.0 アップデート及びパッチ管理について
Oracle Database Appliance 12.1.2.2.0 アップデート及びパッチ管理について
 
新機能によるデータベースシステムの改善ポイント
新機能によるデータベースシステムの改善ポイント新機能によるデータベースシステムの改善ポイント
新機能によるデータベースシステムの改善ポイント
 
Oracle Database 12c Release 1 PSR 12.1.0.2 のご紹介
Oracle Database 12c Release 1 PSR 12.1.0.2 のご紹介Oracle Database 12c Release 1 PSR 12.1.0.2 のご紹介
Oracle Database 12c Release 1 PSR 12.1.0.2 のご紹介
 
Oracle Database Appliance 12.1.2.3.0 アップデート及びパッチ管理について
Oracle Database Appliance 12.1.2.3.0 アップデート及びパッチ管理についてOracle Database Appliance 12.1.2.3.0 アップデート及びパッチ管理について
Oracle Database Appliance 12.1.2.3.0 アップデート及びパッチ管理について
 
Oracle Database Enterprise Edition で解決する データベースシステムの課題 (12c対応版)
Oracle Database Enterprise Edition で解決するデータベースシステムの課題 (12c対応版)Oracle Database Enterprise Edition で解決するデータベースシステムの課題 (12c対応版)
Oracle Database Enterprise Edition で解決する データベースシステムの課題 (12c対応版)
 
Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)
 
New Features in JDK 8
New Features in JDK 8New Features in JDK 8
New Features in JDK 8
 

Similar to Smart Migration to JDK 8

Java 8 - An Overview
Java 8 - An OverviewJava 8 - An Overview
Java 8 - An Overview
Indrajit Das
 
Insight into java 1.8, OOP VS FP
Insight into java 1.8, OOP VS FPInsight into java 1.8, OOP VS FP
Insight into java 1.8, OOP VS FP
Syed Awais Mazhar Bukhari
 
Automatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to InterfacesAutomatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to Interfaces
Raffi Khatchadourian
 
Reactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJavaReactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJava
Ali Muzaffar
 
Colloquium Report
Colloquium ReportColloquium Report
Colloquium Report
Mohammad Faizan
 
Microservices Part 4: Functional Reactive Programming
Microservices Part 4: Functional Reactive ProgrammingMicroservices Part 4: Functional Reactive Programming
Microservices Part 4: Functional Reactive Programming
Araf Karsh Hamid
 
Reactive Applications with Apache Pulsar and Spring Boot
Reactive Applications with Apache Pulsar and Spring BootReactive Applications with Apache Pulsar and Spring Boot
Reactive Applications with Apache Pulsar and Spring Boot
VMware Tanzu
 
Functional reactive programming
Functional reactive programmingFunctional reactive programming
Functional reactive programming
Araf Karsh Hamid
 
C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1
ReKruiTIn.com
 
Functional JavaScript Fundamentals
Functional JavaScript FundamentalsFunctional JavaScript Fundamentals
Functional JavaScript Fundamentals
Srdjan Strbanovic
 
Spring 5 Webflux - Advances in Java 2018
Spring 5 Webflux - Advances in Java 2018Spring 5 Webflux - Advances in Java 2018
Spring 5 Webflux - Advances in Java 2018
Trayan Iliev
 
Microservices with Spring 5 Webflux - jProfessionals
Microservices  with Spring 5 Webflux - jProfessionalsMicroservices  with Spring 5 Webflux - jProfessionals
Microservices with Spring 5 Webflux - jProfessionals
Trayan Iliev
 
Java 8-revealed
Java 8-revealedJava 8-revealed
Java 8-revealed
Hamed Hatami
 
New c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_ivNew c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_iv
Nico Ludwig
 
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsIntroduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Emiel Paasschens
 
Java 8 - Features Overview
Java 8 - Features OverviewJava 8 - Features Overview
Java 8 - Features Overview
Sergii Stets
 
379008-rc217-functionalprogramming
379008-rc217-functionalprogramming379008-rc217-functionalprogramming
379008-rc217-functionalprogrammingLuis Atencio
 
LINQ
LINQLINQ
Java 8 streams
Java 8 streams Java 8 streams
Java 8 streams
Srinivasan Raghvan
 
Unit 1
Unit  1Unit  1
Unit 1
donny101
 

Similar to Smart Migration to JDK 8 (20)

Java 8 - An Overview
Java 8 - An OverviewJava 8 - An Overview
Java 8 - An Overview
 
Insight into java 1.8, OOP VS FP
Insight into java 1.8, OOP VS FPInsight into java 1.8, OOP VS FP
Insight into java 1.8, OOP VS FP
 
Automatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to InterfacesAutomatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to Interfaces
 
Reactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJavaReactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJava
 
Colloquium Report
Colloquium ReportColloquium Report
Colloquium Report
 
Microservices Part 4: Functional Reactive Programming
Microservices Part 4: Functional Reactive ProgrammingMicroservices Part 4: Functional Reactive Programming
Microservices Part 4: Functional Reactive Programming
 
Reactive Applications with Apache Pulsar and Spring Boot
Reactive Applications with Apache Pulsar and Spring BootReactive Applications with Apache Pulsar and Spring Boot
Reactive Applications with Apache Pulsar and Spring Boot
 
Functional reactive programming
Functional reactive programmingFunctional reactive programming
Functional reactive programming
 
C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1
 
Functional JavaScript Fundamentals
Functional JavaScript FundamentalsFunctional JavaScript Fundamentals
Functional JavaScript Fundamentals
 
Spring 5 Webflux - Advances in Java 2018
Spring 5 Webflux - Advances in Java 2018Spring 5 Webflux - Advances in Java 2018
Spring 5 Webflux - Advances in Java 2018
 
Microservices with Spring 5 Webflux - jProfessionals
Microservices  with Spring 5 Webflux - jProfessionalsMicroservices  with Spring 5 Webflux - jProfessionals
Microservices with Spring 5 Webflux - jProfessionals
 
Java 8-revealed
Java 8-revealedJava 8-revealed
Java 8-revealed
 
New c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_ivNew c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_iv
 
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsIntroduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
 
Java 8 - Features Overview
Java 8 - Features OverviewJava 8 - Features Overview
Java 8 - Features Overview
 
379008-rc217-functionalprogramming
379008-rc217-functionalprogramming379008-rc217-functionalprogramming
379008-rc217-functionalprogramming
 
LINQ
LINQLINQ
LINQ
 
Java 8 streams
Java 8 streams Java 8 streams
Java 8 streams
 
Unit 1
Unit  1Unit  1
Unit 1
 

More from Geertjan Wielenga

The Long Walk to Apache NetBeans
The Long Walk to Apache NetBeansThe Long Walk to Apache NetBeans
The Long Walk to Apache NetBeans
Geertjan Wielenga
 
Java Master Class
Java Master ClassJava Master Class
Java Master Class
Geertjan Wielenga
 
Coding from Application Container Cloud to Oracle JET
Coding from Application Container Cloud to Oracle JETCoding from Application Container Cloud to Oracle JET
Coding from Application Container Cloud to Oracle JET
Geertjan Wielenga
 
Session at Oredev 2016.
Session at Oredev 2016.Session at Oredev 2016.
Session at Oredev 2016.
Geertjan Wielenga
 
JFall 2016: Oracle JET Session
JFall 2016: Oracle JET SessionJFall 2016: Oracle JET Session
JFall 2016: Oracle JET Session
Geertjan Wielenga
 
Slovenian Oracle User Group
Slovenian Oracle User GroupSlovenian Oracle User Group
Slovenian Oracle User Group
Geertjan Wielenga
 
Imworld.ro
Imworld.roImworld.ro
Imworld.ro
Geertjan Wielenga
 
Oracle User Group Holland
Oracle User Group HollandOracle User Group Holland
Oracle User Group Holland
Geertjan Wielenga
 
State of NetBeans
State of NetBeansState of NetBeans
State of NetBeans
Geertjan Wielenga
 
Oracle JET, with JET Mobile Content
Oracle JET, with JET Mobile ContentOracle JET, with JET Mobile Content
Oracle JET, with JET Mobile Content
Geertjan Wielenga
 
10 Building Blocks for Enterprise JavaScript
10 Building Blocks for Enterprise JavaScript10 Building Blocks for Enterprise JavaScript
10 Building Blocks for Enterprise JavaScript
Geertjan Wielenga
 
Japanese Introduction to Oracle JET
Japanese Introduction to Oracle JETJapanese Introduction to Oracle JET
Japanese Introduction to Oracle JET
Geertjan Wielenga
 
Oracle JET
Oracle JETOracle JET
Oracle JET
Geertjan Wielenga
 
geecon 2016: "What's Oracle Doing with JavaScript?!"
geecon 2016: "What's Oracle Doing with JavaScript?!"geecon 2016: "What's Oracle Doing with JavaScript?!"
geecon 2016: "What's Oracle Doing with JavaScript?!"
Geertjan Wielenga
 
Technology Evangelism
Technology EvangelismTechnology Evangelism
Technology Evangelism
Geertjan Wielenga
 
Technology evangelist
Technology evangelistTechnology evangelist
Technology evangelist
Geertjan Wielenga
 
Surviving Life in the JavaScript Ecosystem
Surviving Life in the JavaScript EcosystemSurviving Life in the JavaScript Ecosystem
Surviving Life in the JavaScript Ecosystem
Geertjan Wielenga
 
Oracle JET: Enterprise-Ready JavaScript Toolkit
Oracle JET: Enterprise-Ready JavaScript ToolkitOracle JET: Enterprise-Ready JavaScript Toolkit
Oracle JET: Enterprise-Ready JavaScript Toolkit
Geertjan Wielenga
 
NetBeans Workshop at Hanze University of Applied Science, Groningen
NetBeans Workshop at Hanze University of Applied Science, GroningenNetBeans Workshop at Hanze University of Applied Science, Groningen
NetBeans Workshop at Hanze University of Applied Science, Groningen
Geertjan Wielenga
 
Coding for Desktop & Mobile with HTML5 & Java EE
Coding for Desktop & Mobile with HTML5 & Java EECoding for Desktop & Mobile with HTML5 & Java EE
Coding for Desktop & Mobile with HTML5 & Java EE
Geertjan Wielenga
 

More from Geertjan Wielenga (20)

The Long Walk to Apache NetBeans
The Long Walk to Apache NetBeansThe Long Walk to Apache NetBeans
The Long Walk to Apache NetBeans
 
Java Master Class
Java Master ClassJava Master Class
Java Master Class
 
Coding from Application Container Cloud to Oracle JET
Coding from Application Container Cloud to Oracle JETCoding from Application Container Cloud to Oracle JET
Coding from Application Container Cloud to Oracle JET
 
Session at Oredev 2016.
Session at Oredev 2016.Session at Oredev 2016.
Session at Oredev 2016.
 
JFall 2016: Oracle JET Session
JFall 2016: Oracle JET SessionJFall 2016: Oracle JET Session
JFall 2016: Oracle JET Session
 
Slovenian Oracle User Group
Slovenian Oracle User GroupSlovenian Oracle User Group
Slovenian Oracle User Group
 
Imworld.ro
Imworld.roImworld.ro
Imworld.ro
 
Oracle User Group Holland
Oracle User Group HollandOracle User Group Holland
Oracle User Group Holland
 
State of NetBeans
State of NetBeansState of NetBeans
State of NetBeans
 
Oracle JET, with JET Mobile Content
Oracle JET, with JET Mobile ContentOracle JET, with JET Mobile Content
Oracle JET, with JET Mobile Content
 
10 Building Blocks for Enterprise JavaScript
10 Building Blocks for Enterprise JavaScript10 Building Blocks for Enterprise JavaScript
10 Building Blocks for Enterprise JavaScript
 
Japanese Introduction to Oracle JET
Japanese Introduction to Oracle JETJapanese Introduction to Oracle JET
Japanese Introduction to Oracle JET
 
Oracle JET
Oracle JETOracle JET
Oracle JET
 
geecon 2016: "What's Oracle Doing with JavaScript?!"
geecon 2016: "What's Oracle Doing with JavaScript?!"geecon 2016: "What's Oracle Doing with JavaScript?!"
geecon 2016: "What's Oracle Doing with JavaScript?!"
 
Technology Evangelism
Technology EvangelismTechnology Evangelism
Technology Evangelism
 
Technology evangelist
Technology evangelistTechnology evangelist
Technology evangelist
 
Surviving Life in the JavaScript Ecosystem
Surviving Life in the JavaScript EcosystemSurviving Life in the JavaScript Ecosystem
Surviving Life in the JavaScript Ecosystem
 
Oracle JET: Enterprise-Ready JavaScript Toolkit
Oracle JET: Enterprise-Ready JavaScript ToolkitOracle JET: Enterprise-Ready JavaScript Toolkit
Oracle JET: Enterprise-Ready JavaScript Toolkit
 
NetBeans Workshop at Hanze University of Applied Science, Groningen
NetBeans Workshop at Hanze University of Applied Science, GroningenNetBeans Workshop at Hanze University of Applied Science, Groningen
NetBeans Workshop at Hanze University of Applied Science, Groningen
 
Coding for Desktop & Mobile with HTML5 & Java EE
Coding for Desktop & Mobile with HTML5 & Java EECoding for Desktop & Mobile with HTML5 & Java EE
Coding for Desktop & Mobile with HTML5 & Java EE
 

Recently uploaded

Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 

Recently uploaded (20)

Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 

Smart Migration to JDK 8

  • 1. 1
  • 3. Language Changes in Java 8 Themes  From Imperative to Functional – Use modern constructs other newer languages use. – Enhance code readability. – Strip out the boilerplate code. – Stop telling the compiler what to do.  From Sequential to Parallel – Execute code in parallel without extra effort. – Divide problems into subproblems solve subproblems simultaneously and combine the results. – Aggregate operations instead of fork/join. 3
  • 4. Language Changes in Java 8 From Imperative to Functional, From Sequential to Parallel  Virtual extension methods  Functional interfaces  Lambdas  Method references  Streams  Collections  Time  Concurrency  IO/NIO  Reflections and annotations  Miscellaneous 4
  • 5. Building Blocks of Java 8 From Imperative to Functional, From Sequential to Parallel  Virtual extension methods – Break existing code when adding a method to an interface? – Java 8 allows to add new methods to interfaces. – Revolutionary – interface evolution is now possible.  Functional interfaces – A functional interface defines exactly one abstract method, focused on one specific task. – For example, java.lang.Runnable defines one abstract method “run()”. – @FunctionalInterface 5
  • 6. Lambda From Imperative to Functional, From Sequential to Parallel  Remove boilerplate code of anonymous inner classes. Better syntax. 6
  • 7. Demo How to Migrate to Lambdas 7
  • 8. Functions From Imperative to Functional, From Sequential to Parallel  java.util.Function – defines new functional interfaces, in addition to EventHandler, etc. 8
  • 9. Functions From Imperative to Functional, From Sequential to Parallel  java.util.Function – defines new functional interfaces, in addition to EventHandler, etc. New Functional Interfaces Function<T,R> BiFunction, ToIntFunction, LongToIntFunction, etc. Predicate<T> IntPredicate, LongPredicate, DoublePredicate, etc. Consumer<T> IntConsumer, DoubleConsumer, LongConsumer, etc. Supplier<T> IntSupplier, BinarySupplier, DoubleSupplier, etc. BinaryOperator<T> 9 Many Primitive Specializations IntBinaryOperator, IntUnaryOperator, etc.
  • 10. Streams: Pipes & Filters From Imperative to Functional, From Sequential to Parallel  java.util.Stream – provides a pipeline with filters. Source is processed through a pipe.  Each successive aggregate operation in the pipeline is one of: – Intermediate – map, filter, sorted, distinct, limit, skip, substream – Terminal – forEach, sum, collect, reduce, count, findFirst, findAny  Lazy evaluation – process only as needed and as many times as needed, e.g., “findFirst”.  No intermediate storage. 10
  • 11. Streams: Classes & Methods From Imperative to Functional, From Sequential to Parallel IntStream Builder LongStream DoubleStream anyMatch distinct concat noneMatch empty count range of parallel 11 map max peek allMatch forEachOrder findAny flatMap collect min findFirst sequential forEach limit iterate reduce skip sorted toArray filter builder boxed generate
  • 12. Streams: Collections From Imperative to Functional, From Sequential to Parallel  Distinguish between “what should be done” and “how it should be done”.  Collections APIs have been extended. Collections can be exposed as Streams.  Identify and refactor “for” loops. Replace with internal iterations provided by Streams.  That lets you express concurrent processing of elements in parallel. 12
  • 13. 13
  • 14. Demo How to Migrate to Streams 14
  • 15. Method Reference From Imperative to Functional, From Sequential to Parallel  Method references are an abbreviated style for expressing lambdas. x -> String.valueOf(x) x -> x.toString () -> x.toString() () -> new ArrayList() / / / / String::valueOf Object::toString x::toString ArrayList::new  Where a method already exists to perform an operation, a method reference can be used instead of a lambda. 15
  • 16. Demo How to Migrate to Method References 16
  • 17. Automation and Batch Processing From Imperative to Functional, From Sequential to Parallel  Refactoring tool scans across a scope – all projects, single project, single package, file...  Find candidates for upgrading to lambdas, functional operations, and method references. 17
  • 19. Getting Started From Imperative to Functional, From Sequential to Parallel  Download NetBeans IDE 8.  Register JDK 8 in the IDE.  Set JDK 8 on the project.  Change Source Format to JDK 8. 19
  • 21. Community Feedback From Imperative to Functional, From Sequential to Parallel 21
  • 22. Summary From Imperative to Functional, From Sequential to Parallel  Virtual extension methods and functional interfaces make lambdas possible.  Lambdas remove boilerplate code of anonymous inner classes.  Streams provide pipelines, filters, and parallelism to Collections.  Method references are an alternative shorthand for lambdas. 22
  • 24. References From Imperative to Functional, From Sequential to Parallel  http://cr.openjdk.java.net/~briangoetz/lambda/lambda-state-final.html  http://blog.hartveld.com/2013/03/jdk-8-13-interface-default-method.html  http://www.techempower.com/blog/2013/03/26/everything-about-java-8/  http://technology.amis.nl/2013/10/05/java-8-collection-enhancements-leveraging-lambda-expressions-or-how-java- emulates-sql/  http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/Lambda-QuickStart/index.html  http://drunkendev.blogspot.nl/2014/01/migrating-to-jdk-8-with-netbeans.html  http://devoxx.com/display/DV12/Closures+and+Collections+-+the+World+After+Eight  http://refactoring.info/tools/LambdaFicator/ 24
  • 25. 25