SlideShare a Scribd company logo
Functional
Vaadin
Henri Muurimaa, SVP of Services

henri@vaadin.com +358 400 474778 @henrimuurimaa
7
MissionMission
Why do we exist
Make building amazing
web applications easy
Building blocks
Developer
Productivity
Rich
UX
Web application layers
JavaScriptWeb serverBackend Communication
JS
required required required required
Vaadin
required optionalrequired optional
Web application layers
JavaScriptWeb serverBackend Communication
JS
required required required required
Vaadin
required optionalrequired optional
1 layer
vs
3 layers
Less code
Less bugs
Faster time-to-market
> 100.000 developers from
> 10.000 cities
> 450 add-ons in the

marketplace
Other
4 %Asia
20 %
Americas
22 %
Europe
54 %
Open Source community
Apache-licensed
Demo time
github.com/hezamu/WorkoutTracker
What is
Functional
Programming?
A style of programming that
expresses computation as the
evaluation of mathematical
functions
Recursion
Lazy evaluation
Lambda expressions
Type theory
Monads
Referential
transparency
Currying
Entscheidungsproblem
Pattern matching
Tuples
Something practical?
Side effects?
State?
Denied
Denied
Okay…
What’s in it for me?
A new way of thinking
A new way of programming
Write tight, robust and scalable code
What’s hot
in Java 8
Improved
Date API
New Java 8 Date API in action
public int monthAge() {
return (new Date().getYear() - date.getYear()) * 12
+ (new Date().getMonth() - date.getMonth());
}
// Java 8 version with the new Date API
public int monthAge() {
return (int) Period.between(date, LocalDate.now()).toTotalMonths();
}
Lambda
expressions
Anonymous functions
Runnable r = () -> System.out.println("hello lambda!”);
Comparator<Integer> cmp1 = (x, y) -> (x < y) ? -1 : ((x > y) ? 1 : 0);
// Anonymous onsite functions
button.addClickListener(event -> System.out.println("Button clicked!"));
Comparator<Integer> cmp2 = (x, y) -> {
return (x < y) ? -1 : ((x > y) ? 1 : 0); // Need return if not one liner
};
Workout Tracker example
editor.clear.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
editor.clearValues();
updateRating();
}
});
// Java 8 version with a lambda
editor.clear.addClickListener(event -> {
editor.clearValues();
updateRating();
});
Method references with the :: notation
! private void eventHandler(Button.ClickEvent event) {
// do something about the button click
}
button.addClickListener(this::eventHandler);
// If the handler method is static
button.addClickListener(MyClass::eventHandler);
Workout Tracker example
!editor.activity.addValueChangeListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
updateRating();
}
});
// Java 8 version with a method reference
editor.date.addValueChangeListener(this::updateRating);
Streams
Composable with higher order functions
Streams != collections
As lazy as possible
Can be infinite
Input validation
private boolean areInputsValid() {
Component component = null;
for (Iterator<Component> iter = editor.iterator(); iter.hasNext(); iter.next()) {
if (fieldNotValidating(component))
return false;
}
return true;
}
// Java 8 version with anyMatch and a method reference
private boolean areInputsValid() {
return !StreamSupport.stream(editor.spliterator(), true)
.anyMatch(this::fieldNotValidating);
}
Higher order
functions
A function that
takes one or more
functions as input
Returns a new stream by
applying the given function to
all elements of this stream.
!
Map
Returns a new stream
consisting of the elements of
this stream that match the
given predicate.
Filter
SQL analogue: SELECT SQL analogue: WHERE
Workout Tracker Example
!
!
!
// Java 8 version with stream operations
private Stream<Workout> findByAge(int maxMonths) {
return workouts.stream()
.filter(w -> w.monthAge() < maxMonths)
.sorted(Comparator.comparing(Workout::monthAge).reversed());
}
private List<Workout> findByAge(int maxMonths) {
List<Workout> result = new ArrayList<>();
for (Workout w : workouts) {
if (w.monthAge() < maxMonths) {
result.add(w);
}
}
Collections.sort(result, new Comparator<Workout>() {
@Override
public int compare(Workout o1, Workout o2) {
return o2.monthAge() - o1.monthAge();
}
});
!
return result;
}
Scratching the surface of Scala syntax
class Cat(name: String) {
initLitterBox()
def meow(volume: Int = 5) = {
println(s"$name meows " +
(if (volume <= 5) "quietly" else "loudly"))
volume <= 5
}
}
Class body is the constructor
identifier: type notation
Functions with def keyword
Arguments can have default values
Return keyword optional
No semicolons needed
Burn the boilerplate - Workout.java
!
!
!
public void setDuration(int duration) {
this.duration = duration;
}
!
public double getAvgHR() {
return avgHR;
}
!
public void setAvgHR(double avgHR) {
this.avgHR = avgHR;
}
!
public double getMaxHR() {
return maxHR;
}
!
public void setMaxHR(double maxHR) {
this.maxHR = maxHR;
}
!
public int getCalories() {
return calories;
}
!
public void setCalories(int calories) {
this.calories = calories;
}
!
public String getComment() {
return comment;
}
!
public void setComment(String comment) {
this.comment = comment;
}
}
public class Workout {
private String activity;
private Date date;
private int duration, calories;
private double avgHR, maxHR;
private String comment;
!
public Workout(String activity, Date date, int time, double avgHR,
double maxHR, int kcal, String comment) {
this.activity = activity;
this.date = date;
this.duration = time;
this.avgHR = avgHR;
this.maxHR = maxHR;
this.calories = kcal;
this.comment = comment;
}
!
public int monthAge() {
return (int) Period.between(date, LocalDate.now()).toTotalMonths();
}
!
public String getActivity() {
return activity;
}
!
public void setActivity(String activity) {
this.activity = activity;
}
!
public Date getDate() {
return date;
}
!
public void setDate(Date date) {
this.date = date;
}
!
public int getDuration() {
return duration;
}
Equivalent Workout.scala
!
!
!
case class Workout(activity: String, date: LocalDate, duration: Int,
avgHR: Double, maxHR: Double, calories: Int, comment: String) {
def monthAge = Period.between(date, LocalDate.now).toTotalMonths
}
github.com/henrikerola/scaladin
An example
// Scaladin
val layout = new VerticalLayout {
margin = true
!
add(Label("Hello, OSCON!"),
alignment = Alignment.TopCenter)
add(Button("Click me”, handleButtonClick))
}
// Java 7
VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
Label label = new Label(“Hello, OSCON!”);
layout.addComponent(title);
layout.setComponentAlignment(label,
Alignment.TOP_CENTER);
!
Button button = new Button(“Click me", new
Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
handleButtonClick();
}
});
layout.addComponent(button);
Input validation, Java 8 & Scala
// Scaladin version of the editor gives us the components as a Scala Set
// which supports functional operations.
private def areInputsValid = !editor.components.exists(fieldNotValidating)
// Java 8 version with anyMatch and a method reference
private boolean areInputsValid() {
return !StreamSupport.stream(editor.spliterator(), true)
.anyMatch(this::fieldNotValidating);
}
Summary
SLOC comparison
Java 7 Java 8 Scala
UI 267 264 175
Presenter 168 128 84
POJO 82 82 8
All versions: zero lines of HTML, JavaScript, RPC code or browser specific tweaks
Henri Muurimaa, SVP of Services

henri@vaadin.com +358 400 474778 @henrimuurimaa

More Related Content

What's hot

Angular Optimization Web Performance Meetup
Angular Optimization Web Performance MeetupAngular Optimization Web Performance Meetup
Angular Optimization Web Performance Meetup
David Barreto
 
State Models for React with Redux
State Models for React with ReduxState Models for React with Redux
State Models for React with Redux
Stephan Schmidt
 
FullStack Reativo com Spring WebFlux + Angular
FullStack Reativo com Spring WebFlux + AngularFullStack Reativo com Spring WebFlux + Angular
FullStack Reativo com Spring WebFlux + Angular
Loiane Groner
 
Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018
Loiane Groner
 
Serverless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsServerless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applications
Loiane Groner
 
Full-Stack Reativo com Spring WebFlux + Angular - Devs Java Girl
Full-Stack Reativo com Spring WebFlux + Angular - Devs Java GirlFull-Stack Reativo com Spring WebFlux + Angular - Devs Java Girl
Full-Stack Reativo com Spring WebFlux + Angular - Devs Java Girl
Loiane Groner
 
Gerenciamento de estado no Angular com NgRx
Gerenciamento de estado no Angular com NgRxGerenciamento de estado no Angular com NgRx
Gerenciamento de estado no Angular com NgRx
Loiane Groner
 
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018
Loiane Groner
 
Full-Stack Reativo com Spring WebFlux + Angular - FiqueEmCasaConf
Full-Stack Reativo com Spring WebFlux + Angular - FiqueEmCasaConfFull-Stack Reativo com Spring WebFlux + Angular - FiqueEmCasaConf
Full-Stack Reativo com Spring WebFlux + Angular - FiqueEmCasaConf
Loiane Groner
 
Let's discover React and Redux with TypeScript
Let's discover React and Redux with TypeScriptLet's discover React and Redux with TypeScript
Let's discover React and Redux with TypeScript
Mathieu Savy
 
Presente e Futuro: Java EE.next()
Presente e Futuro: Java EE.next()Presente e Futuro: Java EE.next()
Presente e Futuro: Java EE.next()
Bruno Borges
 
Functional Reactive Endpoints using Spring 5
Functional Reactive Endpoints using Spring 5Functional Reactive Endpoints using Spring 5
Functional Reactive Endpoints using Spring 5
Rory Preddy
 
Open sourcing the store
Open sourcing the storeOpen sourcing the store
Open sourcing the store
Mike Nakhimovich
 
Quick start with React | DreamLab Academy #2
Quick start with React | DreamLab Academy #2Quick start with React | DreamLab Academy #2
Quick start with React | DreamLab Academy #2
DreamLab
 
Reactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-JavaReactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-Java
Kasun Indrasiri
 
Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019
Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019
Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019
Loiane Groner
 
Angular & RXJS: examples and use cases
Angular & RXJS: examples and use casesAngular & RXJS: examples and use cases
Angular & RXJS: examples and use cases
Fabio Biondi
 
Apollo server II
Apollo server IIApollo server II
Apollo server II
NodeXperts
 
React on Rails - RailsConf 2017 (Phoenix)
 React on Rails - RailsConf 2017 (Phoenix) React on Rails - RailsConf 2017 (Phoenix)
React on Rails - RailsConf 2017 (Phoenix)
Jo Cranford
 
ProvJS: Six Months of ReactJS and Redux
ProvJS:  Six Months of ReactJS and ReduxProvJS:  Six Months of ReactJS and Redux
ProvJS: Six Months of ReactJS and Redux
Thom Nichols
 

What's hot (20)

Angular Optimization Web Performance Meetup
Angular Optimization Web Performance MeetupAngular Optimization Web Performance Meetup
Angular Optimization Web Performance Meetup
 
State Models for React with Redux
State Models for React with ReduxState Models for React with Redux
State Models for React with Redux
 
FullStack Reativo com Spring WebFlux + Angular
FullStack Reativo com Spring WebFlux + AngularFullStack Reativo com Spring WebFlux + Angular
FullStack Reativo com Spring WebFlux + Angular
 
Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018
 
Serverless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsServerless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applications
 
Full-Stack Reativo com Spring WebFlux + Angular - Devs Java Girl
Full-Stack Reativo com Spring WebFlux + Angular - Devs Java GirlFull-Stack Reativo com Spring WebFlux + Angular - Devs Java Girl
Full-Stack Reativo com Spring WebFlux + Angular - Devs Java Girl
 
Gerenciamento de estado no Angular com NgRx
Gerenciamento de estado no Angular com NgRxGerenciamento de estado no Angular com NgRx
Gerenciamento de estado no Angular com NgRx
 
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018
 
Full-Stack Reativo com Spring WebFlux + Angular - FiqueEmCasaConf
Full-Stack Reativo com Spring WebFlux + Angular - FiqueEmCasaConfFull-Stack Reativo com Spring WebFlux + Angular - FiqueEmCasaConf
Full-Stack Reativo com Spring WebFlux + Angular - FiqueEmCasaConf
 
Let's discover React and Redux with TypeScript
Let's discover React and Redux with TypeScriptLet's discover React and Redux with TypeScript
Let's discover React and Redux with TypeScript
 
Presente e Futuro: Java EE.next()
Presente e Futuro: Java EE.next()Presente e Futuro: Java EE.next()
Presente e Futuro: Java EE.next()
 
Functional Reactive Endpoints using Spring 5
Functional Reactive Endpoints using Spring 5Functional Reactive Endpoints using Spring 5
Functional Reactive Endpoints using Spring 5
 
Open sourcing the store
Open sourcing the storeOpen sourcing the store
Open sourcing the store
 
Quick start with React | DreamLab Academy #2
Quick start with React | DreamLab Academy #2Quick start with React | DreamLab Academy #2
Quick start with React | DreamLab Academy #2
 
Reactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-JavaReactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-Java
 
Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019
Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019
Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019
 
Angular & RXJS: examples and use cases
Angular & RXJS: examples and use casesAngular & RXJS: examples and use cases
Angular & RXJS: examples and use cases
 
Apollo server II
Apollo server IIApollo server II
Apollo server II
 
React on Rails - RailsConf 2017 (Phoenix)
 React on Rails - RailsConf 2017 (Phoenix) React on Rails - RailsConf 2017 (Phoenix)
React on Rails - RailsConf 2017 (Phoenix)
 
ProvJS: Six Months of ReactJS and Redux
ProvJS:  Six Months of ReactJS and ReduxProvJS:  Six Months of ReactJS and Redux
ProvJS: Six Months of ReactJS and Redux
 

Viewers also liked

Vaadin Components
Vaadin ComponentsVaadin Components
Vaadin Components
Joonas Lehtinen
 
RIA security based on OWASP Top 10
RIA security based on OWASP Top 10RIA security based on OWASP Top 10
RIA security based on OWASP Top 10
lastrand
 
Introduction to Vaadin 7
Introduction to Vaadin 7Introduction to Vaadin 7
Introduction to Vaadin 7
lastrand
 
Using Vaadin to create HTML5-enabled web apps in pure Scala
Using Vaadin to create HTML5-enabled web apps in pure ScalaUsing Vaadin to create HTML5-enabled web apps in pure Scala
Using Vaadin to create HTML5-enabled web apps in pure Scala
hezamu
 
Improving the HTML Table
Improving the HTML TableImproving the HTML Table
Improving the HTML Table
lastrand
 
Vaadin Designer (Labs release) @ GWT.create 2015
Vaadin Designer (Labs release) @ GWT.create 2015 Vaadin Designer (Labs release) @ GWT.create 2015
Vaadin Designer (Labs release) @ GWT.create 2015
marcenglund
 
IBM BusinessConnect 2014 DK: Bluemix and Vaadin Snapshot
IBM BusinessConnect 2014 DK: Bluemix and Vaadin SnapshotIBM BusinessConnect 2014 DK: Bluemix and Vaadin Snapshot
IBM BusinessConnect 2014 DK: Bluemix and Vaadin Snapshot
Ville Ingman
 
A shortcut to mobile app development: Enterprise Mobility 2014 Helsinki
A shortcut to mobile app development: Enterprise Mobility 2014 HelsinkiA shortcut to mobile app development: Enterprise Mobility 2014 Helsinki
A shortcut to mobile app development: Enterprise Mobility 2014 Helsinki
Ville Ingman
 
Binding business data to vaadin components
Binding business data to vaadin componentsBinding business data to vaadin components
Binding business data to vaadin components
Peter Lehto
 
Introduction to Vaadin, GWT.create 2015
Introduction to Vaadin, GWT.create 2015Introduction to Vaadin, GWT.create 2015
Introduction to Vaadin, GWT.create 2015
hezamu
 
Building impressive layout systems with vaadin
Building impressive layout systems with vaadinBuilding impressive layout systems with vaadin
Building impressive layout systems with vaadin
Peter Lehto
 
Techlunch - Dependency Injection with Vaadin
Techlunch - Dependency Injection with VaadinTechlunch - Dependency Injection with Vaadin
Techlunch - Dependency Injection with Vaadin
Peter Lehto
 
Vaadin 7 - Java Enterprise Edition integration
Vaadin 7 - Java Enterprise Edition integrationVaadin 7 - Java Enterprise Edition integration
Vaadin 7 - Java Enterprise Edition integration
Peter Lehto
 
Migration from vaadin 6 to vaadin 7 devoxx france 2013
Migration from vaadin 6 to vaadin 7   devoxx france 2013Migration from vaadin 6 to vaadin 7   devoxx france 2013
Migration from vaadin 6 to vaadin 7 devoxx france 2013
Joonas Lehtinen
 
Building mobile applications with Vaadin TouchKit
Building mobile applications with Vaadin TouchKitBuilding mobile applications with Vaadin TouchKit
Building mobile applications with Vaadin TouchKit
Sami Ekblad
 
WebApp controlled Parrot AR Drone with Vaadin and Spring Boot
WebApp controlled Parrot AR Drone with Vaadin and Spring BootWebApp controlled Parrot AR Drone with Vaadin and Spring Boot
WebApp controlled Parrot AR Drone with Vaadin and Spring Boot
Peter Lehto
 
Web Application Security and Modern Frameworks
Web Application Security and Modern FrameworksWeb Application Security and Modern Frameworks
Web Application Security and Modern Frameworks
lastrand
 
Remote controlling Parrot AR drone with Vaadin & Spring Boot @ GWT.create
Remote controlling Parrot AR drone with Vaadin & Spring Boot @ GWT.createRemote controlling Parrot AR drone with Vaadin & Spring Boot @ GWT.create
Remote controlling Parrot AR drone with Vaadin & Spring Boot @ GWT.create
Peter Lehto
 
Vaadin Introduction, 7.3 edition
Vaadin Introduction, 7.3 editionVaadin Introduction, 7.3 edition
Vaadin Introduction, 7.3 edition
Joonas Lehtinen
 
Vaadin and Spring at Devoxx UK 2015
Vaadin and Spring at Devoxx UK 2015Vaadin and Spring at Devoxx UK 2015
Vaadin and Spring at Devoxx UK 2015
Sami Ekblad
 

Viewers also liked (20)

Vaadin Components
Vaadin ComponentsVaadin Components
Vaadin Components
 
RIA security based on OWASP Top 10
RIA security based on OWASP Top 10RIA security based on OWASP Top 10
RIA security based on OWASP Top 10
 
Introduction to Vaadin 7
Introduction to Vaadin 7Introduction to Vaadin 7
Introduction to Vaadin 7
 
Using Vaadin to create HTML5-enabled web apps in pure Scala
Using Vaadin to create HTML5-enabled web apps in pure ScalaUsing Vaadin to create HTML5-enabled web apps in pure Scala
Using Vaadin to create HTML5-enabled web apps in pure Scala
 
Improving the HTML Table
Improving the HTML TableImproving the HTML Table
Improving the HTML Table
 
Vaadin Designer (Labs release) @ GWT.create 2015
Vaadin Designer (Labs release) @ GWT.create 2015 Vaadin Designer (Labs release) @ GWT.create 2015
Vaadin Designer (Labs release) @ GWT.create 2015
 
IBM BusinessConnect 2014 DK: Bluemix and Vaadin Snapshot
IBM BusinessConnect 2014 DK: Bluemix and Vaadin SnapshotIBM BusinessConnect 2014 DK: Bluemix and Vaadin Snapshot
IBM BusinessConnect 2014 DK: Bluemix and Vaadin Snapshot
 
A shortcut to mobile app development: Enterprise Mobility 2014 Helsinki
A shortcut to mobile app development: Enterprise Mobility 2014 HelsinkiA shortcut to mobile app development: Enterprise Mobility 2014 Helsinki
A shortcut to mobile app development: Enterprise Mobility 2014 Helsinki
 
Binding business data to vaadin components
Binding business data to vaadin componentsBinding business data to vaadin components
Binding business data to vaadin components
 
Introduction to Vaadin, GWT.create 2015
Introduction to Vaadin, GWT.create 2015Introduction to Vaadin, GWT.create 2015
Introduction to Vaadin, GWT.create 2015
 
Building impressive layout systems with vaadin
Building impressive layout systems with vaadinBuilding impressive layout systems with vaadin
Building impressive layout systems with vaadin
 
Techlunch - Dependency Injection with Vaadin
Techlunch - Dependency Injection with VaadinTechlunch - Dependency Injection with Vaadin
Techlunch - Dependency Injection with Vaadin
 
Vaadin 7 - Java Enterprise Edition integration
Vaadin 7 - Java Enterprise Edition integrationVaadin 7 - Java Enterprise Edition integration
Vaadin 7 - Java Enterprise Edition integration
 
Migration from vaadin 6 to vaadin 7 devoxx france 2013
Migration from vaadin 6 to vaadin 7   devoxx france 2013Migration from vaadin 6 to vaadin 7   devoxx france 2013
Migration from vaadin 6 to vaadin 7 devoxx france 2013
 
Building mobile applications with Vaadin TouchKit
Building mobile applications with Vaadin TouchKitBuilding mobile applications with Vaadin TouchKit
Building mobile applications with Vaadin TouchKit
 
WebApp controlled Parrot AR Drone with Vaadin and Spring Boot
WebApp controlled Parrot AR Drone with Vaadin and Spring BootWebApp controlled Parrot AR Drone with Vaadin and Spring Boot
WebApp controlled Parrot AR Drone with Vaadin and Spring Boot
 
Web Application Security and Modern Frameworks
Web Application Security and Modern FrameworksWeb Application Security and Modern Frameworks
Web Application Security and Modern Frameworks
 
Remote controlling Parrot AR drone with Vaadin & Spring Boot @ GWT.create
Remote controlling Parrot AR drone with Vaadin & Spring Boot @ GWT.createRemote controlling Parrot AR drone with Vaadin & Spring Boot @ GWT.create
Remote controlling Parrot AR drone with Vaadin & Spring Boot @ GWT.create
 
Vaadin Introduction, 7.3 edition
Vaadin Introduction, 7.3 editionVaadin Introduction, 7.3 edition
Vaadin Introduction, 7.3 edition
 
Vaadin and Spring at Devoxx UK 2015
Vaadin and Spring at Devoxx UK 2015Vaadin and Spring at Devoxx UK 2015
Vaadin and Spring at Devoxx UK 2015
 

Similar to Functional Vaadin talk at OSCON 2014

Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy code
ShriKant Vashishtha
 
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
Daniel Bryant
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every day
Vadym Khondar
 
Rethinking Syncing at AltConf 2019
Rethinking Syncing at AltConf 2019Rethinking Syncing at AltConf 2019
Rethinking Syncing at AltConf 2019
Joe Keeley
 
Android dev toolbox
Android dev toolboxAndroid dev toolbox
Android dev toolbox
Shem Magnezi
 
Android best practices
Android best practicesAndroid best practices
Android best practices
Jose Manuel Ortega Candel
 
Применение паттерна Page Object для автоматизации веб сервисов
Применение паттерна Page Object для автоматизации веб сервисовПрименение паттерна Page Object для автоматизации веб сервисов
Применение паттерна Page Object для автоматизации веб сервисов
COMAQA.BY
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
Jeff Durta
 
What is new in java 8 concurrency
What is new in java 8 concurrencyWhat is new in java 8 concurrency
What is new in java 8 concurrency
kshanth2101
 
Bot builder v4 HOL
Bot builder v4 HOLBot builder v4 HOL
Bot builder v4 HOL
Cheah Eng Soon
 
How to perform debounce in react
How to perform debounce in reactHow to perform debounce in react
How to perform debounce in react
BOSC Tech Labs
 
Booa8 Slide 09
Booa8 Slide 09Booa8 Slide 09
Booa8 Slide 09
oswchavez
 
Clean Code: Chapter 3 Function
Clean Code: Chapter 3 FunctionClean Code: Chapter 3 Function
Clean Code: Chapter 3 Function
Kent Huang
 
React & The Art of Managing Complexity
React &  The Art of Managing ComplexityReact &  The Art of Managing Complexity
React & The Art of Managing Complexity
Ryan Anklam
 
Structure on a freeform world
Structure on a freeform worldStructure on a freeform world
Structure on a freeform world
Ikai (藍奕凱) Lan
 
New features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptx
New features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptxNew features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptx
New features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptx
Muralidharan Deenathayalan
 
Rx workshop
Rx workshopRx workshop
Rx workshop
Ryan Riley
 
Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015
Morris Singer
 
What's Coming in Spring 3.0
What's Coming in Spring 3.0What's Coming in Spring 3.0
What's Coming in Spring 3.0
Matt Raible
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
Rick Warren
 

Similar to Functional Vaadin talk at OSCON 2014 (20)

Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy code
 
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every day
 
Rethinking Syncing at AltConf 2019
Rethinking Syncing at AltConf 2019Rethinking Syncing at AltConf 2019
Rethinking Syncing at AltConf 2019
 
Android dev toolbox
Android dev toolboxAndroid dev toolbox
Android dev toolbox
 
Android best practices
Android best practicesAndroid best practices
Android best practices
 
Применение паттерна Page Object для автоматизации веб сервисов
Применение паттерна Page Object для автоматизации веб сервисовПрименение паттерна Page Object для автоматизации веб сервисов
Применение паттерна Page Object для автоматизации веб сервисов
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
What is new in java 8 concurrency
What is new in java 8 concurrencyWhat is new in java 8 concurrency
What is new in java 8 concurrency
 
Bot builder v4 HOL
Bot builder v4 HOLBot builder v4 HOL
Bot builder v4 HOL
 
How to perform debounce in react
How to perform debounce in reactHow to perform debounce in react
How to perform debounce in react
 
Booa8 Slide 09
Booa8 Slide 09Booa8 Slide 09
Booa8 Slide 09
 
Clean Code: Chapter 3 Function
Clean Code: Chapter 3 FunctionClean Code: Chapter 3 Function
Clean Code: Chapter 3 Function
 
React & The Art of Managing Complexity
React &  The Art of Managing ComplexityReact &  The Art of Managing Complexity
React & The Art of Managing Complexity
 
Structure on a freeform world
Structure on a freeform worldStructure on a freeform world
Structure on a freeform world
 
New features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptx
New features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptxNew features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptx
New features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptx
 
Rx workshop
Rx workshopRx workshop
Rx workshop
 
Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015
 
What's Coming in Spring 3.0
What's Coming in Spring 3.0What's Coming in Spring 3.0
What's Coming in Spring 3.0
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
 

Recently uploaded

一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
kgyxske
 
Microsoft-Power-Platform-Adoption-Planning.pptx
Microsoft-Power-Platform-Adoption-Planning.pptxMicrosoft-Power-Platform-Adoption-Planning.pptx
Microsoft-Power-Platform-Adoption-Planning.pptx
jrodriguezq3110
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
Bert Jan Schrijver
 
Streamlining End-to-End Testing Automation
Streamlining End-to-End Testing AutomationStreamlining End-to-End Testing Automation
Streamlining End-to-End Testing Automation
Anand Bagmar
 
Beginner's Guide to Observability@Devoxx PL 2024
Beginner's  Guide to Observability@Devoxx PL 2024Beginner's  Guide to Observability@Devoxx PL 2024
Beginner's Guide to Observability@Devoxx PL 2024
michniczscribd
 
Software Test Automation - A Comprehensive Guide on Automated Testing.pdf
Software Test Automation - A Comprehensive Guide on Automated Testing.pdfSoftware Test Automation - A Comprehensive Guide on Automated Testing.pdf
Software Test Automation - A Comprehensive Guide on Automated Testing.pdf
kalichargn70th171
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
Tier1 app
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
Alberto Brandolini
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
ervikas4
 
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA ComplianceSecure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
ICS
 
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
campbellclarkson
 
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical OperationsEnsuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
OnePlan Solutions
 
Orca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container OrchestrationOrca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container Orchestration
Pedro J. Molina
 
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
kalichargn70th171
 
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
Luigi Fugaro
 
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptxOperational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
sandeepmenon62
 
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
dhavalvaghelanectarb
 
Computer Science & Engineering VI Sem- New Syllabus.pdf
Computer Science & Engineering VI Sem- New Syllabus.pdfComputer Science & Engineering VI Sem- New Syllabus.pdf
Computer Science & Engineering VI Sem- New Syllabus.pdf
chandangoswami40933
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio, Inc.
 

Recently uploaded (20)

一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
 
Microsoft-Power-Platform-Adoption-Planning.pptx
Microsoft-Power-Platform-Adoption-Planning.pptxMicrosoft-Power-Platform-Adoption-Planning.pptx
Microsoft-Power-Platform-Adoption-Planning.pptx
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
 
Streamlining End-to-End Testing Automation
Streamlining End-to-End Testing AutomationStreamlining End-to-End Testing Automation
Streamlining End-to-End Testing Automation
 
Beginner's Guide to Observability@Devoxx PL 2024
Beginner's  Guide to Observability@Devoxx PL 2024Beginner's  Guide to Observability@Devoxx PL 2024
Beginner's Guide to Observability@Devoxx PL 2024
 
Software Test Automation - A Comprehensive Guide on Automated Testing.pdf
Software Test Automation - A Comprehensive Guide on Automated Testing.pdfSoftware Test Automation - A Comprehensive Guide on Automated Testing.pdf
Software Test Automation - A Comprehensive Guide on Automated Testing.pdf
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
 
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA ComplianceSecure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
 
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
 
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical OperationsEnsuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
 
Orca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container OrchestrationOrca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container Orchestration
 
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
 
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
 
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptxOperational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
 
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
 
Computer Science & Engineering VI Sem- New Syllabus.pdf
Computer Science & Engineering VI Sem- New Syllabus.pdfComputer Science & Engineering VI Sem- New Syllabus.pdf
Computer Science & Engineering VI Sem- New Syllabus.pdf
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
 

Functional Vaadin talk at OSCON 2014

  • 1. Functional Vaadin Henri Muurimaa, SVP of Services
 henri@vaadin.com +358 400 474778 @henrimuurimaa 7
  • 2.
  • 3. MissionMission Why do we exist Make building amazing web applications easy
  • 6. Web application layers JavaScriptWeb serverBackend Communication JS required required required required Vaadin required optionalrequired optional
  • 7. Web application layers JavaScriptWeb serverBackend Communication JS required required required required Vaadin required optionalrequired optional 1 layer vs 3 layers Less code Less bugs Faster time-to-market
  • 8. > 100.000 developers from > 10.000 cities > 450 add-ons in the
 marketplace Other 4 %Asia 20 % Americas 22 % Europe 54 % Open Source community Apache-licensed
  • 12. A style of programming that expresses computation as the evaluation of mathematical functions
  • 13. Recursion Lazy evaluation Lambda expressions Type theory Monads Referential transparency Currying Entscheidungsproblem Pattern matching Tuples
  • 16. What’s in it for me? A new way of thinking A new way of programming Write tight, robust and scalable code
  • 19. New Java 8 Date API in action public int monthAge() { return (new Date().getYear() - date.getYear()) * 12 + (new Date().getMonth() - date.getMonth()); } // Java 8 version with the new Date API public int monthAge() { return (int) Period.between(date, LocalDate.now()).toTotalMonths(); }
  • 21. Anonymous functions Runnable r = () -> System.out.println("hello lambda!”); Comparator<Integer> cmp1 = (x, y) -> (x < y) ? -1 : ((x > y) ? 1 : 0); // Anonymous onsite functions button.addClickListener(event -> System.out.println("Button clicked!")); Comparator<Integer> cmp2 = (x, y) -> { return (x < y) ? -1 : ((x > y) ? 1 : 0); // Need return if not one liner };
  • 22. Workout Tracker example editor.clear.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { editor.clearValues(); updateRating(); } }); // Java 8 version with a lambda editor.clear.addClickListener(event -> { editor.clearValues(); updateRating(); });
  • 23. Method references with the :: notation ! private void eventHandler(Button.ClickEvent event) { // do something about the button click } button.addClickListener(this::eventHandler); // If the handler method is static button.addClickListener(MyClass::eventHandler);
  • 24. Workout Tracker example !editor.activity.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { updateRating(); } }); // Java 8 version with a method reference editor.date.addValueChangeListener(this::updateRating);
  • 26. Composable with higher order functions Streams != collections As lazy as possible Can be infinite
  • 27. Input validation private boolean areInputsValid() { Component component = null; for (Iterator<Component> iter = editor.iterator(); iter.hasNext(); iter.next()) { if (fieldNotValidating(component)) return false; } return true; } // Java 8 version with anyMatch and a method reference private boolean areInputsValid() { return !StreamSupport.stream(editor.spliterator(), true) .anyMatch(this::fieldNotValidating); }
  • 29. A function that takes one or more functions as input
  • 30. Returns a new stream by applying the given function to all elements of this stream. ! Map Returns a new stream consisting of the elements of this stream that match the given predicate. Filter SQL analogue: SELECT SQL analogue: WHERE
  • 31. Workout Tracker Example ! ! ! // Java 8 version with stream operations private Stream<Workout> findByAge(int maxMonths) { return workouts.stream() .filter(w -> w.monthAge() < maxMonths) .sorted(Comparator.comparing(Workout::monthAge).reversed()); } private List<Workout> findByAge(int maxMonths) { List<Workout> result = new ArrayList<>(); for (Workout w : workouts) { if (w.monthAge() < maxMonths) { result.add(w); } } Collections.sort(result, new Comparator<Workout>() { @Override public int compare(Workout o1, Workout o2) { return o2.monthAge() - o1.monthAge(); } }); ! return result; }
  • 32.
  • 33. Scratching the surface of Scala syntax class Cat(name: String) { initLitterBox() def meow(volume: Int = 5) = { println(s"$name meows " + (if (volume <= 5) "quietly" else "loudly")) volume <= 5 } } Class body is the constructor identifier: type notation Functions with def keyword Arguments can have default values Return keyword optional No semicolons needed
  • 34. Burn the boilerplate - Workout.java ! ! ! public void setDuration(int duration) { this.duration = duration; } ! public double getAvgHR() { return avgHR; } ! public void setAvgHR(double avgHR) { this.avgHR = avgHR; } ! public double getMaxHR() { return maxHR; } ! public void setMaxHR(double maxHR) { this.maxHR = maxHR; } ! public int getCalories() { return calories; } ! public void setCalories(int calories) { this.calories = calories; } ! public String getComment() { return comment; } ! public void setComment(String comment) { this.comment = comment; } } public class Workout { private String activity; private Date date; private int duration, calories; private double avgHR, maxHR; private String comment; ! public Workout(String activity, Date date, int time, double avgHR, double maxHR, int kcal, String comment) { this.activity = activity; this.date = date; this.duration = time; this.avgHR = avgHR; this.maxHR = maxHR; this.calories = kcal; this.comment = comment; } ! public int monthAge() { return (int) Period.between(date, LocalDate.now()).toTotalMonths(); } ! public String getActivity() { return activity; } ! public void setActivity(String activity) { this.activity = activity; } ! public Date getDate() { return date; } ! public void setDate(Date date) { this.date = date; } ! public int getDuration() { return duration; }
  • 35. Equivalent Workout.scala ! ! ! case class Workout(activity: String, date: LocalDate, duration: Int, avgHR: Double, maxHR: Double, calories: Int, comment: String) { def monthAge = Period.between(date, LocalDate.now).toTotalMonths }
  • 37. An example // Scaladin val layout = new VerticalLayout { margin = true ! add(Label("Hello, OSCON!"), alignment = Alignment.TopCenter) add(Button("Click me”, handleButtonClick)) } // Java 7 VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); Label label = new Label(“Hello, OSCON!”); layout.addComponent(title); layout.setComponentAlignment(label, Alignment.TOP_CENTER); ! Button button = new Button(“Click me", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { handleButtonClick(); } }); layout.addComponent(button);
  • 38. Input validation, Java 8 & Scala // Scaladin version of the editor gives us the components as a Scala Set // which supports functional operations. private def areInputsValid = !editor.components.exists(fieldNotValidating) // Java 8 version with anyMatch and a method reference private boolean areInputsValid() { return !StreamSupport.stream(editor.spliterator(), true) .anyMatch(this::fieldNotValidating); }
  • 40. SLOC comparison Java 7 Java 8 Scala UI 267 264 175 Presenter 168 128 84 POJO 82 82 8 All versions: zero lines of HTML, JavaScript, RPC code or browser specific tweaks
  • 41. Henri Muurimaa, SVP of Services
 henri@vaadin.com +358 400 474778 @henrimuurimaa