SlideShare a Scribd company logo
©2016 IKERLAN. All rights reserved©2016 IKERLAN. All rights reserved
Ikerlan – Java 8
Ángel Conde– [DevOps & Data Engineer]
2016/4/6
©2016 IKERLAN. All rights reserved 2
Outline
1. Maven – Solving the Dependency Hell
2. Java 8 – What's new
3. Logging – Understanding the JVM logging system
4. Useful libraries – do not reinvent the wheel
5. Testing – Mocks Everywhere
©2016 IKERLAN. All rights reserved 3
Automatize your builds
Tasks called phases.
Dependency management via repositories.
XML configuration, quite verbose.
Plugin support.
1. validate
2. generate-sources
3. process-sources
4. generate-resources
5. process-resources
6. compile
mvn compile
©2016 IKERLAN. All rights reserved 4
<project xmlns=http://maven.apache.org/POM/4.0.0 …. ">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>es.ikerlan.ulma</groupId>
<artifactId>ulma-supervisor</artifactId>
<version>1.0</version>
</parent>
<artifactId>compactor</artifactId>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<name>compactor</name>
<repositories> </repositories>
<dependencies> </dependencies>
<build>
<plugins> </plugins>
</build>
</project>
– A “pom” to rule them all
©2016 IKERLAN. All rights reserved 5
– Dependencies
<dependencies>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-a</artifactId>
<version>1.0</version>
<exclusions>
<exclusion>
<groupId>group-c</groupId>
<artifactId>excluded-artifact</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-b</artifactId>
<version>1.0</version>
<type>bar</type>
<scope>runtime</scope>
</dependency>
</dependencies>
Transitive dependency support & Scope Limit.
©2016 IKERLAN. All rights reserved 6
– Useful plugins
1. maven-shade-plugin: Uber Jar generation.
2. findbugs-maven-plugin: static code analysis.
3. maven-surefire-plugin: automates JUnit tests.
4. maven-enforcer-plugin: enforces configuration.
5. docker-maven-plugin: generates Docker images.
6. exec-maven-plugin: provides execution capabilities.
©2016 IKERLAN. All rights reserved 7
– The Future?
Google’s Maven “successor”
Groovy-based DSL instead of XML.
DAG in order to solve tasks ordering.
Dependency solver.
Multi-language support.
©2016 IKERLAN. All rights reserved 8
Outline
1. Maven – Solving the Dependency Hell
2. Java 8 – What's new
3. Logging – Understanding the JVM logging system
4. Useful libraries – do not reinvent the wheel
5. Testing – Mocks Everywhere
©2016 IKERLAN. All rights reserved 9
Java 8 – Default Methods
Allows developer to add new methods to old interfaces.
Used to add Lambdas and Streams support to the JDK8.
public interface oldInterface {
public void existingMethod();
default public void newDefaultMethod() {
System.out.println("New default method" " is added
in interface");
}
}
©2016 IKERLAN. All rights reserved 10
Java 8 – Functional Interfaces
Interfaces with only one method.
Used for providing lambda support to the JDK.
@FunctionalInterface
public interface Predicate<T>{
boolean test(T t);
}
public static <T> List<T> filter(List<T> list, Predicate<T> p) {
List<T> results = new ArrayList<>();
for(T s: list){
if(p.test(s)){
results.add(s);
}
}
return results;
}
©2016 IKERLAN. All rights reserved 11
Java 8 – Method References
Class::Method  meaning “use this method as a value”
File[] hiddenFiles = new File(".").listFiles(File::isHidden);
File[] hiddenFiles = new File(".").listFiles(new FileFilter()
{
public boolean accept(File file) {
return file.isHidden();
}
});
Vanilla Java
Java 8
©2016 IKERLAN. All rights reserved 12
Java 8 – Anonymous Functions (Lambdas)
public static boolean isGreenApple(Apple apple) {
return "green".equals(apple.getColor());
}
Java 7
filterApples(inventory, (Apple a) -> a.getWeight() > 150 );
Java 8
1.(int x, int y) -> x + y
2.(x, y) -> x - y
3.() -> 42
4.(String s) -> System.out.println(s)
5.x -> 2 * x
Introduce the idea of functions into the language.
Kind of anonymous method with compact syntax.
©2016 IKERLAN. All rights reserved 13
Java 8 – Streams
Lazy Immutable evaluated collections.
Partially evaluated —elements remain to be generated.
Exhausted — when its elements are used up.
An array, a collection, a generator function, or an IO channel.
Two types of operations: intermediate and terminal.
A partially evaluated stream may have infinitely elements.
IntStream.iterate(0, i -> i + 2)
.limit(100)
.forEach(System.out::println);
Stream.generate(Math::random)
.limit(5)
.forEach(System.out::println);
©2016 IKERLAN. All rights reserved 14
Java 8 – Streams (II)
©2016 IKERLAN. All rights reserved 15
Java 8 – Streams (III)
List<String> title = Arrays.asList("Java8", “Rules");
Stream<String> s = title.stream();
s.forEach(System.out::println);
s.forEach(System.out::println);
s.stream()
.map(w -> w.split(""))
.flatMap(Arrays::stream)
.distinct()
.collect(Collectors.toList());
s.stream()
.map(word -> word.split(""))
.map(Arrays::stream)
.distinct()
.collect(toList());
List<Integer> result = numbers.stream()
.peek(x -> System.out.println("from stream: " + x))
.map(x -> x + 17)
.collect(toList());
ERROR!! Stream already closed
ERROR!! Nested Stream….
©2016 IKERLAN. All rights reserved 16
Java 8 – Streams (IV)
List<String> names = menu.stream()
.filter(d -> d.getCalories() > 300)
.map(Dish::getName)
.limit(3)
.collect(toList());
String traderStr = transactions.stream()
.map(transaction -> transaction.getTrader().getName())
.distinct()
.sorted()
.reduce("", (n1, n2) -> n1 + n2);
String traderStr = transactions.stream()
.map(transaction -> transaction.getTrader().getName())
.distinct()
.sorted()
.collect(joining());
The second is faster because it avoids String duplication with StringBuilder
©2016 IKERLAN. All rights reserved 17
Java 8 – Streams (V)
String traderStr = transactions.stream()
.map(transaction -> transaction.getTrader().getName())
.distinct()
.sorted()
.collect(joining());
Map<Dish.Type, List<Dish>>
dishesByType = menu.stream()
collect(groupingBy(Dish::getType));
The Collector Interface
Implement various useful reduction operations.
©2016 IKERLAN. All rights reserved 18
Java 8 – Streams (VI)
Immutable parallelism: fork / join pools
©2016 IKERLAN. All rights reserved 19
Java 8 – Streams (VII)
public static long rangedSum(long n) {
return LongStream.rangeClosed(1, n)
.parallel()
.reduce(0L, Long::sum);
}
public static long parallelSum(long n) {
return Stream.iterate(1L, i -> i + 1)
.limit(n)
.parallel()
.reduce(0L, Long::sum);
}
Avoid this, very slow!! (iterate is not parallel friendly)
Very fast because LongStream provide longs NOT Longs
©2016 IKERLAN. All rights reserved 20
Java 8 – Streams (VII)
public static long sideEffectSum(long n) {
Accumulator accumulator = new Accumulator();
LongStream.rangeClosed(1,n).
forEach(accumulator::add);
return accumulator.total;
}
public class Accumulator {
public long total = 0;
public void add(long value) {
total += value; }
}
stream.parallel()
.filter(...)
.sequential()
.map(...)
.parallel()
.reduce();
Fine-Grained control?
AVOID MUTABLE STRUCTURES!!!!
©2016 IKERLAN. All rights reserved 21
Java 8 – More Features
Data & Time API (based on Joda-Time library).
CompletableFuture, futures the functional way.
Optionals for avoiding null checking.
LocalDate today = LocalDate.now();
LocalDate nextWeek = today.plus(1, ChronoUnit.WEEKS);
public void renderPage(CharSequence source) {
List<ImageInfo> info = scanForImageInfo(source);
info.forEach(imageInfo -> CompletableFuture
.supplyAsync(imageInfo::downloadImage)
.thenAccept(this::renderImage));
renderText(source); }
String name = computer.flatMap(Computer::getSoundcard)
.flatMap(Soundcard::getUSB) .map(USB::getVersion)
.orElse("UNKNOWN");
©2016 IKERLAN. All rights reserved 22
Outline
1. Maven – Solving the Dependency Hell
2. Java 8 – What's new
3. Logging – Understanding the JVM logging system
4. Useful libraries – do not reinvent the wheel
5. Testing – Mocks Everywhere
©2016 IKERLAN. All rights reserved 23
Logging Systems
In Java world different implementations.
1. Interface.
2. Underlying implementation.
3. Configuration.
private final Logger log = LoggerFactory.getLogger(LogExample.class);
public static void main(String... args) {
log.error("Something's wrong here");
}
static
©2016 IKERLAN. All rights reserved 24
Slf4j
©2016 IKERLAN. All rights reserved 25
Slf4j
©2016 IKERLAN. All rights reserved 26
Slf4j with Logback
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT“ class="c...core.ConsoleAppender">
<encoder class="c...encoder.PatternLayoutEncoder">
<Pattern>
%d{HH:mm:ss} [%thread] %-5level %logger{36} %msg%n
</Pattern>
</encoder>
</appender>
<logger name="es.ikerlan.ulma" level="warn"/>
<logger name="org.apache.hadoop" level="error"/>
<logger name="parquet.hadoop" level="error"/>
<root level="debug">
<appender-ref ref="STDOUT" />
</root>
</configuration>
Logback.xml
©2016 IKERLAN. All rights reserved 27
Outline
1. Maven – Solving the Dependency Hell
2. Java 8 – What's new
3. Logging – Understanding the JVM logging system
4. Useful libraries – do not reinvent the wheel
5. Testing – Mocks Everywhere
©2016 IKERLAN. All rights reserved 28
Useful Libraries – lombok
https://projectlombok.org/ – useful decorators.
- @Data: adds setters/getters, constructor.
- @Slf4j: adds logging via SLF4J.
@Data
public class DataExample {
private final String name;
private double score;
}
lombok
@Data
public class DataExample {
private final String name;
private double score;
public String getName(){
return name;
}
public double getScore(){
return score;
}
……
}
vanilla Java
©2016 IKERLAN. All rights reserved 29
Useful Libraries
http://www.jcabi.com/ – more decorators and utilities (Amazon,
Json, XML….)
https://github.com/google/guava – Google Java core libraries, from
caches, parsers, optionals, collections, etc.
https://commons.apache.org/ – apache hosted libraries.
©2016 IKERLAN. All rights reserved 30
Outline
1. Maven – Solving the Dependency Hell
2. Java 8 – What's new
3. Logging – Understanding the JVM logging system
4. Useful libraries – do not reinvent the wheel
5. Testing – Mocks Everywhere
©2016 IKERLAN. All rights reserved 31
– Testing
The facto standard unit testing library for Java.
Best tool for Test Driven development.
@Test : methods to be executed on testing
@Before: executed before each test
@After: executed before each test
@BeforeClass: runs once before the test fixture.
@AfterClass: runs once before the entire test fixture.
©2016 IKERLAN. All rights reserved 32
– Testing
@Test
public void multiplicationOfZeroIntegersShouldReturnZero()
{
// MyClass is tested
MyClass tester = new MyClass();
// assert statements
assertEquals("10 x 0 must be 0", 0, tester.multiply(10, 0));
assertEquals("0 x 10 must be 0", 0, tester.multiply(0, 10));
assertEquals("0 x 0 must be 0", 0, tester.multiply(0, 0));
}
An example:
©2016 IKERLAN. All rights reserved 33
– Mocks everywhere
mock()/@Mock: create mock from an object.
when()/given() : to specify how a mock should behave
spy()/@Spy: partial mocking, methods are invoked but still can be verified and stubbed
@InjectMocks: automatically inject mocks/spies fields annotated with @Spy or @Mock
verify(): to check methods were called with given arguments
Mock Object library for testing.
©2016 IKERLAN. All rights reserved 34
– Mocks everywhere (II)
@Spy
private LocationService locationService;
@Test
public final void spyTest() {
//mock the object
Location loc = new Location();
//we mock the locationService.getLocation method from the real
object using mockito
doReturn(loc).when(locationService).getLocation("test");
Location found = locationService.getLocation("test");
assertEquals(loc, found);
}
An example with @Spy:
©2016 IKERLAN. All rights reserved
IKERLAN Polo Garaia
C/ Goiru , 9
20500 Arrasate-Mondragón
Tel.: 943 71 02 12
Fax: 943 79 69 44
IKERLAN Unidad de energía
Parque Tecnológico de Álava,
C/ Juan de la Cierva, 1
01510 Miñano
Tel.: 945 29 70 32
Fax: 943 79 69 44
www.ikerlan.es
ORONA IDeO - Innovation city
Pol. Industrial Galarreta,
Parcela 10.5, Edificio A3
20120 Hernani
Tel.: 945 29 70 32
Fax: 943 79 69 44
IKERLAN
Pº. J. Mª. Arizmendiarrieta, 2
20500 Arrasate-Mondragón
Tel.: 943 71 24 00
Fax: 943 79 69 44
Questions?
Email: aconde@ikerlan.es
Thanks for your attention:
Ad

More Related Content

What's hot (20)

Android Data Persistence
Android Data PersistenceAndroid Data Persistence
Android Data Persistence
Romain Rochegude
 
Code red SUM
Code red SUMCode red SUM
Code red SUM
Shumail Haider
 
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen ChinHacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
jaxconf
 
Code generation for alternative languages
Code generation for alternative languagesCode generation for alternative languages
Code generation for alternative languages
Rafael Winterhalter
 
Java设置环境变量
Java设置环境变量Java设置环境变量
Java设置环境变量
Zianed Hou
 
Ejemplo radio
Ejemplo radioEjemplo radio
Ejemplo radio
lupe ga
 
Hello click click boom
Hello click click boomHello click click boom
Hello click click boom
symbian_mgl
 
Spock
SpockSpock
Spock
Naiyer Asif
 
The Ring programming language version 1.7 book - Part 12 of 196
The Ring programming language version 1.7 book - Part 12 of 196The Ring programming language version 1.7 book - Part 12 of 196
The Ring programming language version 1.7 book - Part 12 of 196
Mahmoud Samir Fayed
 
GDG DevFest 2015 - Reactive approach for slowpokes
GDG DevFest 2015 - Reactive approach for slowpokesGDG DevFest 2015 - Reactive approach for slowpokes
GDG DevFest 2015 - Reactive approach for slowpokes
Sergey Tarasevich
 
Selenium Webdriver with data driven framework
Selenium Webdriver with data driven frameworkSelenium Webdriver with data driven framework
Selenium Webdriver with data driven framework
David Rajah Selvaraj
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)
Alok Kumar
 
The Ring programming language version 1.6 book - Part 11 of 189
The Ring programming language version 1.6 book - Part 11 of 189The Ring programming language version 1.6 book - Part 11 of 189
The Ring programming language version 1.6 book - Part 11 of 189
Mahmoud Samir Fayed
 
OSGi and Eclipse RCP
OSGi and Eclipse RCPOSGi and Eclipse RCP
OSGi and Eclipse RCP
Eric Jain
 
Use of Apache Commons and Utilities
Use of Apache Commons and UtilitiesUse of Apache Commons and Utilities
Use of Apache Commons and Utilities
Pramod Kumar
 
ScalaDays 2014 - Reactive Scala 3D Game Engine
ScalaDays 2014 - Reactive Scala 3D Game Engine ScalaDays 2014 - Reactive Scala 3D Game Engine
ScalaDays 2014 - Reactive Scala 3D Game Engine
Aleksandar Prokopec
 
Asegúr@IT IV - Remote File Downloading
Asegúr@IT IV - Remote File DownloadingAsegúr@IT IV - Remote File Downloading
Asegúr@IT IV - Remote File Downloading
Chema Alonso
 
#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
탑크리에듀(구로디지털단지역3번출구 2분거리)
 
201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing
wahyuseptiansyah
 
spring-tutorial
spring-tutorialspring-tutorial
spring-tutorial
Arjun Shanka
 
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen ChinHacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
jaxconf
 
Code generation for alternative languages
Code generation for alternative languagesCode generation for alternative languages
Code generation for alternative languages
Rafael Winterhalter
 
Java设置环境变量
Java设置环境变量Java设置环境变量
Java设置环境变量
Zianed Hou
 
Ejemplo radio
Ejemplo radioEjemplo radio
Ejemplo radio
lupe ga
 
Hello click click boom
Hello click click boomHello click click boom
Hello click click boom
symbian_mgl
 
The Ring programming language version 1.7 book - Part 12 of 196
The Ring programming language version 1.7 book - Part 12 of 196The Ring programming language version 1.7 book - Part 12 of 196
The Ring programming language version 1.7 book - Part 12 of 196
Mahmoud Samir Fayed
 
GDG DevFest 2015 - Reactive approach for slowpokes
GDG DevFest 2015 - Reactive approach for slowpokesGDG DevFest 2015 - Reactive approach for slowpokes
GDG DevFest 2015 - Reactive approach for slowpokes
Sergey Tarasevich
 
Selenium Webdriver with data driven framework
Selenium Webdriver with data driven frameworkSelenium Webdriver with data driven framework
Selenium Webdriver with data driven framework
David Rajah Selvaraj
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)
Alok Kumar
 
The Ring programming language version 1.6 book - Part 11 of 189
The Ring programming language version 1.6 book - Part 11 of 189The Ring programming language version 1.6 book - Part 11 of 189
The Ring programming language version 1.6 book - Part 11 of 189
Mahmoud Samir Fayed
 
OSGi and Eclipse RCP
OSGi and Eclipse RCPOSGi and Eclipse RCP
OSGi and Eclipse RCP
Eric Jain
 
Use of Apache Commons and Utilities
Use of Apache Commons and UtilitiesUse of Apache Commons and Utilities
Use of Apache Commons and Utilities
Pramod Kumar
 
ScalaDays 2014 - Reactive Scala 3D Game Engine
ScalaDays 2014 - Reactive Scala 3D Game Engine ScalaDays 2014 - Reactive Scala 3D Game Engine
ScalaDays 2014 - Reactive Scala 3D Game Engine
Aleksandar Prokopec
 
Asegúr@IT IV - Remote File Downloading
Asegúr@IT IV - Remote File DownloadingAsegúr@IT IV - Remote File Downloading
Asegúr@IT IV - Remote File Downloading
Chema Alonso
 
#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
탑크리에듀(구로디지털단지역3번출구 2분거리)
 
201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing
wahyuseptiansyah
 

Viewers also liked (13)

Jhon sanchez
Jhon sanchezJhon sanchez
Jhon sanchez
maira alejandra jaimes pastos
 
word
wordword
word
maira alejandra jaimes pastos
 
I.S.C. Class XII Sample Papers 2016
I.S.C. Class XII Sample Papers 2016I.S.C. Class XII Sample Papers 2016
I.S.C. Class XII Sample Papers 2016
APEX INSTITUTE
 
TECNOADICCIONES
TECNOADICCIONESTECNOADICCIONES
TECNOADICCIONES
cvfvcvfv
 
Veien til Thought Leadership i et innholdsperspektiv | Content Performance 2015
Veien til Thought Leadership i et innholdsperspektiv | Content Performance 2015Veien til Thought Leadership i et innholdsperspektiv | Content Performance 2015
Veien til Thought Leadership i et innholdsperspektiv | Content Performance 2015
Content Marketing Norge
 
Runyan Recommendation Letter
Runyan Recommendation LetterRunyan Recommendation Letter
Runyan Recommendation Letter
Patrick Carroll
 
GUIANG CV (1)
GUIANG CV (1)GUIANG CV (1)
GUIANG CV (1)
Janelli Guiang
 
Attachment a-3.8.2011-minutes
Attachment a-3.8.2011-minutesAttachment a-3.8.2011-minutes
Attachment a-3.8.2011-minutes
DeepDude
 
5 Keys to Content Marketing
5 Keys to Content Marketing5 Keys to Content Marketing
5 Keys to Content Marketing
Content Marketing Norge
 
INFINITY MMN
INFINITY MMNINFINITY MMN
INFINITY MMN
Marcelino Matos
 
BBOM Apresentação e Plano Marketing Oficial
BBOM Apresentação e Plano Marketing OficialBBOM Apresentação e Plano Marketing Oficial
BBOM Apresentação e Plano Marketing Oficial
Alecsandro Moraes
 
Microservices Architecture for Web Applications using Serverless Computing wi...
Microservices Architecture for Web Applications using Serverless Computing wi...Microservices Architecture for Web Applications using Serverless Computing wi...
Microservices Architecture for Web Applications using Serverless Computing wi...
Mitoc Group
 
Building Scalable Web Applications using Microservices Architecture and NodeJ...
Building Scalable Web Applications using Microservices Architecture and NodeJ...Building Scalable Web Applications using Microservices Architecture and NodeJ...
Building Scalable Web Applications using Microservices Architecture and NodeJ...
Mitoc Group
 
I.S.C. Class XII Sample Papers 2016
I.S.C. Class XII Sample Papers 2016I.S.C. Class XII Sample Papers 2016
I.S.C. Class XII Sample Papers 2016
APEX INSTITUTE
 
TECNOADICCIONES
TECNOADICCIONESTECNOADICCIONES
TECNOADICCIONES
cvfvcvfv
 
Veien til Thought Leadership i et innholdsperspektiv | Content Performance 2015
Veien til Thought Leadership i et innholdsperspektiv | Content Performance 2015Veien til Thought Leadership i et innholdsperspektiv | Content Performance 2015
Veien til Thought Leadership i et innholdsperspektiv | Content Performance 2015
Content Marketing Norge
 
Runyan Recommendation Letter
Runyan Recommendation LetterRunyan Recommendation Letter
Runyan Recommendation Letter
Patrick Carroll
 
Attachment a-3.8.2011-minutes
Attachment a-3.8.2011-minutesAttachment a-3.8.2011-minutes
Attachment a-3.8.2011-minutes
DeepDude
 
BBOM Apresentação e Plano Marketing Oficial
BBOM Apresentação e Plano Marketing OficialBBOM Apresentação e Plano Marketing Oficial
BBOM Apresentação e Plano Marketing Oficial
Alecsandro Moraes
 
Microservices Architecture for Web Applications using Serverless Computing wi...
Microservices Architecture for Web Applications using Serverless Computing wi...Microservices Architecture for Web Applications using Serverless Computing wi...
Microservices Architecture for Web Applications using Serverless Computing wi...
Mitoc Group
 
Building Scalable Web Applications using Microservices Architecture and NodeJ...
Building Scalable Web Applications using Microservices Architecture and NodeJ...Building Scalable Web Applications using Microservices Architecture and NodeJ...
Building Scalable Web Applications using Microservices Architecture and NodeJ...
Mitoc Group
 
Ad

Similar to Modern Java Development (20)

Java
JavaJava
Java
박 경민
 
DevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern JavaDevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern Java
Henri Tremblay
 
What`s new in Java 7
What`s new in Java 7What`s new in Java 7
What`s new in Java 7
Georgian Micsa
 
55j7
55j755j7
55j7
swein2
 
모던자바의 역습
모던자바의 역습모던자바의 역습
모던자바의 역습
DoHyun Jung
 
Intro to Reactive Thinking and RxJava 2
Intro to Reactive Thinking and RxJava 2Intro to Reactive Thinking and RxJava 2
Intro to Reactive Thinking and RxJava 2
JollyRogers5
 
Java 5 and 6 New Features
Java 5 and 6 New FeaturesJava 5 and 6 New Features
Java 5 and 6 New Features
Jussi Pohjolainen
 
Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)
Martijn Verburg
 
What is new in Java 8
What is new in Java 8What is new in Java 8
What is new in Java 8
Sandeep Kr. Singh
 
Java features. Java 8, 9, 10, 11
Java features. Java 8, 9, 10, 11Java features. Java 8, 9, 10, 11
Java features. Java 8, 9, 10, 11
Ivelin Yanev
 
Java7 New Features and Code Examples
Java7 New Features and Code ExamplesJava7 New Features and Code Examples
Java7 New Features and Code Examples
Naresh Chintalcheru
 
55 new things in Java 7 - Devoxx France
55 new things in Java 7 - Devoxx France55 new things in Java 7 - Devoxx France
55 new things in Java 7 - Devoxx France
David Delabassee
 
New Features in JDK 8
New Features in JDK 8New Features in JDK 8
New Features in JDK 8
Martin Toshev
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
Mattias Karlsson
 
Nantes Jug - Java 7
Nantes Jug - Java 7Nantes Jug - Java 7
Nantes Jug - Java 7
Sébastien Prunier
 
wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?
Scott Leberknight
 
Lambda Functions in Java 8
Lambda Functions in Java 8Lambda Functions in Java 8
Lambda Functions in Java 8
Ganesh Samarthyam
 
Cloud nativeworkshop
Cloud nativeworkshopCloud nativeworkshop
Cloud nativeworkshop
Emily Jiang
 
Java Language fundamental
Java Language fundamentalJava Language fundamental
Java Language fundamental
Infoviaan Technologies
 
New features in jdk8 iti
New features in jdk8 itiNew features in jdk8 iti
New features in jdk8 iti
Ahmed mar3y
 
DevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern JavaDevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern Java
Henri Tremblay
 
모던자바의 역습
모던자바의 역습모던자바의 역습
모던자바의 역습
DoHyun Jung
 
Intro to Reactive Thinking and RxJava 2
Intro to Reactive Thinking and RxJava 2Intro to Reactive Thinking and RxJava 2
Intro to Reactive Thinking and RxJava 2
JollyRogers5
 
Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)
Martijn Verburg
 
Java features. Java 8, 9, 10, 11
Java features. Java 8, 9, 10, 11Java features. Java 8, 9, 10, 11
Java features. Java 8, 9, 10, 11
Ivelin Yanev
 
Java7 New Features and Code Examples
Java7 New Features and Code ExamplesJava7 New Features and Code Examples
Java7 New Features and Code Examples
Naresh Chintalcheru
 
55 new things in Java 7 - Devoxx France
55 new things in Java 7 - Devoxx France55 new things in Java 7 - Devoxx France
55 new things in Java 7 - Devoxx France
David Delabassee
 
New Features in JDK 8
New Features in JDK 8New Features in JDK 8
New Features in JDK 8
Martin Toshev
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
Mattias Karlsson
 
Cloud nativeworkshop
Cloud nativeworkshopCloud nativeworkshop
Cloud nativeworkshop
Emily Jiang
 
New features in jdk8 iti
New features in jdk8 itiNew features in jdk8 iti
New features in jdk8 iti
Ahmed mar3y
 
Ad

More from Angel Conde Manjon (7)

Software Realibility on the Big Data Era
Software Realibility on the Big Data EraSoftware Realibility on the Big Data Era
Software Realibility on the Big Data Era
Angel Conde Manjon
 
Evolución hacia las plataformas de datos modernas, el Edge-to-cloud continuum
Evolución hacia las plataformas de datos modernas, el Edge-to-cloud continuumEvolución hacia las plataformas de datos modernas, el Edge-to-cloud continuum
Evolución hacia las plataformas de datos modernas, el Edge-to-cloud continuum
Angel Conde Manjon
 
Continous Delivery and Continous Integration at IKERLAN
Continous Delivery and Continous Integration at IKERLANContinous Delivery and Continous Integration at IKERLAN
Continous Delivery and Continous Integration at IKERLAN
Angel Conde Manjon
 
Towards an Unified API for Spark and the IIoT
Towards an Unified API for Spark and the IIoTTowards an Unified API for Spark and the IIoT
Towards an Unified API for Spark and the IIoT
Angel Conde Manjon
 
Solving the Industry 4.0. challenges on the logistics domain using Apache Mesos
Solving the Industry 4.0. challenges on the logistics domain using Apache MesosSolving the Industry 4.0. challenges on the logistics domain using Apache Mesos
Solving the Industry 4.0. challenges on the logistics domain using Apache Mesos
Angel Conde Manjon
 
Modern Software Development
Modern Software DevelopmentModern Software Development
Modern Software Development
Angel Conde Manjon
 
Ph.D. Defense
Ph.D. Defense Ph.D. Defense
Ph.D. Defense
Angel Conde Manjon
 
Software Realibility on the Big Data Era
Software Realibility on the Big Data EraSoftware Realibility on the Big Data Era
Software Realibility on the Big Data Era
Angel Conde Manjon
 
Evolución hacia las plataformas de datos modernas, el Edge-to-cloud continuum
Evolución hacia las plataformas de datos modernas, el Edge-to-cloud continuumEvolución hacia las plataformas de datos modernas, el Edge-to-cloud continuum
Evolución hacia las plataformas de datos modernas, el Edge-to-cloud continuum
Angel Conde Manjon
 
Continous Delivery and Continous Integration at IKERLAN
Continous Delivery and Continous Integration at IKERLANContinous Delivery and Continous Integration at IKERLAN
Continous Delivery and Continous Integration at IKERLAN
Angel Conde Manjon
 
Towards an Unified API for Spark and the IIoT
Towards an Unified API for Spark and the IIoTTowards an Unified API for Spark and the IIoT
Towards an Unified API for Spark and the IIoT
Angel Conde Manjon
 
Solving the Industry 4.0. challenges on the logistics domain using Apache Mesos
Solving the Industry 4.0. challenges on the logistics domain using Apache MesosSolving the Industry 4.0. challenges on the logistics domain using Apache Mesos
Solving the Industry 4.0. challenges on the logistics domain using Apache Mesos
Angel Conde Manjon
 

Recently uploaded (20)

Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 

Modern Java Development

  • 1. ©2016 IKERLAN. All rights reserved©2016 IKERLAN. All rights reserved Ikerlan – Java 8 Ángel Conde– [DevOps & Data Engineer] 2016/4/6
  • 2. ©2016 IKERLAN. All rights reserved 2 Outline 1. Maven – Solving the Dependency Hell 2. Java 8 – What's new 3. Logging – Understanding the JVM logging system 4. Useful libraries – do not reinvent the wheel 5. Testing – Mocks Everywhere
  • 3. ©2016 IKERLAN. All rights reserved 3 Automatize your builds Tasks called phases. Dependency management via repositories. XML configuration, quite verbose. Plugin support. 1. validate 2. generate-sources 3. process-sources 4. generate-resources 5. process-resources 6. compile mvn compile
  • 4. ©2016 IKERLAN. All rights reserved 4 <project xmlns=http://maven.apache.org/POM/4.0.0 …. "> <modelVersion>4.0.0</modelVersion> <parent> <groupId>es.ikerlan.ulma</groupId> <artifactId>ulma-supervisor</artifactId> <version>1.0</version> </parent> <artifactId>compactor</artifactId> <packaging>jar</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> <name>compactor</name> <repositories> </repositories> <dependencies> </dependencies> <build> <plugins> </plugins> </build> </project> – A “pom” to rule them all
  • 5. ©2016 IKERLAN. All rights reserved 5 – Dependencies <dependencies> <dependency> <groupId>group-a</groupId> <artifactId>artifact-a</artifactId> <version>1.0</version> <exclusions> <exclusion> <groupId>group-c</groupId> <artifactId>excluded-artifact</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>group-a</groupId> <artifactId>artifact-b</artifactId> <version>1.0</version> <type>bar</type> <scope>runtime</scope> </dependency> </dependencies> Transitive dependency support & Scope Limit.
  • 6. ©2016 IKERLAN. All rights reserved 6 – Useful plugins 1. maven-shade-plugin: Uber Jar generation. 2. findbugs-maven-plugin: static code analysis. 3. maven-surefire-plugin: automates JUnit tests. 4. maven-enforcer-plugin: enforces configuration. 5. docker-maven-plugin: generates Docker images. 6. exec-maven-plugin: provides execution capabilities.
  • 7. ©2016 IKERLAN. All rights reserved 7 – The Future? Google’s Maven “successor” Groovy-based DSL instead of XML. DAG in order to solve tasks ordering. Dependency solver. Multi-language support.
  • 8. ©2016 IKERLAN. All rights reserved 8 Outline 1. Maven – Solving the Dependency Hell 2. Java 8 – What's new 3. Logging – Understanding the JVM logging system 4. Useful libraries – do not reinvent the wheel 5. Testing – Mocks Everywhere
  • 9. ©2016 IKERLAN. All rights reserved 9 Java 8 – Default Methods Allows developer to add new methods to old interfaces. Used to add Lambdas and Streams support to the JDK8. public interface oldInterface { public void existingMethod(); default public void newDefaultMethod() { System.out.println("New default method" " is added in interface"); } }
  • 10. ©2016 IKERLAN. All rights reserved 10 Java 8 – Functional Interfaces Interfaces with only one method. Used for providing lambda support to the JDK. @FunctionalInterface public interface Predicate<T>{ boolean test(T t); } public static <T> List<T> filter(List<T> list, Predicate<T> p) { List<T> results = new ArrayList<>(); for(T s: list){ if(p.test(s)){ results.add(s); } } return results; }
  • 11. ©2016 IKERLAN. All rights reserved 11 Java 8 – Method References Class::Method  meaning “use this method as a value” File[] hiddenFiles = new File(".").listFiles(File::isHidden); File[] hiddenFiles = new File(".").listFiles(new FileFilter() { public boolean accept(File file) { return file.isHidden(); } }); Vanilla Java Java 8
  • 12. ©2016 IKERLAN. All rights reserved 12 Java 8 – Anonymous Functions (Lambdas) public static boolean isGreenApple(Apple apple) { return "green".equals(apple.getColor()); } Java 7 filterApples(inventory, (Apple a) -> a.getWeight() > 150 ); Java 8 1.(int x, int y) -> x + y 2.(x, y) -> x - y 3.() -> 42 4.(String s) -> System.out.println(s) 5.x -> 2 * x Introduce the idea of functions into the language. Kind of anonymous method with compact syntax.
  • 13. ©2016 IKERLAN. All rights reserved 13 Java 8 – Streams Lazy Immutable evaluated collections. Partially evaluated —elements remain to be generated. Exhausted — when its elements are used up. An array, a collection, a generator function, or an IO channel. Two types of operations: intermediate and terminal. A partially evaluated stream may have infinitely elements. IntStream.iterate(0, i -> i + 2) .limit(100) .forEach(System.out::println); Stream.generate(Math::random) .limit(5) .forEach(System.out::println);
  • 14. ©2016 IKERLAN. All rights reserved 14 Java 8 – Streams (II)
  • 15. ©2016 IKERLAN. All rights reserved 15 Java 8 – Streams (III) List<String> title = Arrays.asList("Java8", “Rules"); Stream<String> s = title.stream(); s.forEach(System.out::println); s.forEach(System.out::println); s.stream() .map(w -> w.split("")) .flatMap(Arrays::stream) .distinct() .collect(Collectors.toList()); s.stream() .map(word -> word.split("")) .map(Arrays::stream) .distinct() .collect(toList()); List<Integer> result = numbers.stream() .peek(x -> System.out.println("from stream: " + x)) .map(x -> x + 17) .collect(toList()); ERROR!! Stream already closed ERROR!! Nested Stream….
  • 16. ©2016 IKERLAN. All rights reserved 16 Java 8 – Streams (IV) List<String> names = menu.stream() .filter(d -> d.getCalories() > 300) .map(Dish::getName) .limit(3) .collect(toList()); String traderStr = transactions.stream() .map(transaction -> transaction.getTrader().getName()) .distinct() .sorted() .reduce("", (n1, n2) -> n1 + n2); String traderStr = transactions.stream() .map(transaction -> transaction.getTrader().getName()) .distinct() .sorted() .collect(joining()); The second is faster because it avoids String duplication with StringBuilder
  • 17. ©2016 IKERLAN. All rights reserved 17 Java 8 – Streams (V) String traderStr = transactions.stream() .map(transaction -> transaction.getTrader().getName()) .distinct() .sorted() .collect(joining()); Map<Dish.Type, List<Dish>> dishesByType = menu.stream() collect(groupingBy(Dish::getType)); The Collector Interface Implement various useful reduction operations.
  • 18. ©2016 IKERLAN. All rights reserved 18 Java 8 – Streams (VI) Immutable parallelism: fork / join pools
  • 19. ©2016 IKERLAN. All rights reserved 19 Java 8 – Streams (VII) public static long rangedSum(long n) { return LongStream.rangeClosed(1, n) .parallel() .reduce(0L, Long::sum); } public static long parallelSum(long n) { return Stream.iterate(1L, i -> i + 1) .limit(n) .parallel() .reduce(0L, Long::sum); } Avoid this, very slow!! (iterate is not parallel friendly) Very fast because LongStream provide longs NOT Longs
  • 20. ©2016 IKERLAN. All rights reserved 20 Java 8 – Streams (VII) public static long sideEffectSum(long n) { Accumulator accumulator = new Accumulator(); LongStream.rangeClosed(1,n). forEach(accumulator::add); return accumulator.total; } public class Accumulator { public long total = 0; public void add(long value) { total += value; } } stream.parallel() .filter(...) .sequential() .map(...) .parallel() .reduce(); Fine-Grained control? AVOID MUTABLE STRUCTURES!!!!
  • 21. ©2016 IKERLAN. All rights reserved 21 Java 8 – More Features Data & Time API (based on Joda-Time library). CompletableFuture, futures the functional way. Optionals for avoiding null checking. LocalDate today = LocalDate.now(); LocalDate nextWeek = today.plus(1, ChronoUnit.WEEKS); public void renderPage(CharSequence source) { List<ImageInfo> info = scanForImageInfo(source); info.forEach(imageInfo -> CompletableFuture .supplyAsync(imageInfo::downloadImage) .thenAccept(this::renderImage)); renderText(source); } String name = computer.flatMap(Computer::getSoundcard) .flatMap(Soundcard::getUSB) .map(USB::getVersion) .orElse("UNKNOWN");
  • 22. ©2016 IKERLAN. All rights reserved 22 Outline 1. Maven – Solving the Dependency Hell 2. Java 8 – What's new 3. Logging – Understanding the JVM logging system 4. Useful libraries – do not reinvent the wheel 5. Testing – Mocks Everywhere
  • 23. ©2016 IKERLAN. All rights reserved 23 Logging Systems In Java world different implementations. 1. Interface. 2. Underlying implementation. 3. Configuration. private final Logger log = LoggerFactory.getLogger(LogExample.class); public static void main(String... args) { log.error("Something's wrong here"); } static
  • 24. ©2016 IKERLAN. All rights reserved 24 Slf4j
  • 25. ©2016 IKERLAN. All rights reserved 25 Slf4j
  • 26. ©2016 IKERLAN. All rights reserved 26 Slf4j with Logback <?xml version="1.0" encoding="UTF-8"?> <configuration> <appender name="STDOUT“ class="c...core.ConsoleAppender"> <encoder class="c...encoder.PatternLayoutEncoder"> <Pattern> %d{HH:mm:ss} [%thread] %-5level %logger{36} %msg%n </Pattern> </encoder> </appender> <logger name="es.ikerlan.ulma" level="warn"/> <logger name="org.apache.hadoop" level="error"/> <logger name="parquet.hadoop" level="error"/> <root level="debug"> <appender-ref ref="STDOUT" /> </root> </configuration> Logback.xml
  • 27. ©2016 IKERLAN. All rights reserved 27 Outline 1. Maven – Solving the Dependency Hell 2. Java 8 – What's new 3. Logging – Understanding the JVM logging system 4. Useful libraries – do not reinvent the wheel 5. Testing – Mocks Everywhere
  • 28. ©2016 IKERLAN. All rights reserved 28 Useful Libraries – lombok https://projectlombok.org/ – useful decorators. - @Data: adds setters/getters, constructor. - @Slf4j: adds logging via SLF4J. @Data public class DataExample { private final String name; private double score; } lombok @Data public class DataExample { private final String name; private double score; public String getName(){ return name; } public double getScore(){ return score; } …… } vanilla Java
  • 29. ©2016 IKERLAN. All rights reserved 29 Useful Libraries http://www.jcabi.com/ – more decorators and utilities (Amazon, Json, XML….) https://github.com/google/guava – Google Java core libraries, from caches, parsers, optionals, collections, etc. https://commons.apache.org/ – apache hosted libraries.
  • 30. ©2016 IKERLAN. All rights reserved 30 Outline 1. Maven – Solving the Dependency Hell 2. Java 8 – What's new 3. Logging – Understanding the JVM logging system 4. Useful libraries – do not reinvent the wheel 5. Testing – Mocks Everywhere
  • 31. ©2016 IKERLAN. All rights reserved 31 – Testing The facto standard unit testing library for Java. Best tool for Test Driven development. @Test : methods to be executed on testing @Before: executed before each test @After: executed before each test @BeforeClass: runs once before the test fixture. @AfterClass: runs once before the entire test fixture.
  • 32. ©2016 IKERLAN. All rights reserved 32 – Testing @Test public void multiplicationOfZeroIntegersShouldReturnZero() { // MyClass is tested MyClass tester = new MyClass(); // assert statements assertEquals("10 x 0 must be 0", 0, tester.multiply(10, 0)); assertEquals("0 x 10 must be 0", 0, tester.multiply(0, 10)); assertEquals("0 x 0 must be 0", 0, tester.multiply(0, 0)); } An example:
  • 33. ©2016 IKERLAN. All rights reserved 33 – Mocks everywhere mock()/@Mock: create mock from an object. when()/given() : to specify how a mock should behave spy()/@Spy: partial mocking, methods are invoked but still can be verified and stubbed @InjectMocks: automatically inject mocks/spies fields annotated with @Spy or @Mock verify(): to check methods were called with given arguments Mock Object library for testing.
  • 34. ©2016 IKERLAN. All rights reserved 34 – Mocks everywhere (II) @Spy private LocationService locationService; @Test public final void spyTest() { //mock the object Location loc = new Location(); //we mock the locationService.getLocation method from the real object using mockito doReturn(loc).when(locationService).getLocation("test"); Location found = locationService.getLocation("test"); assertEquals(loc, found); } An example with @Spy:
  • 35. ©2016 IKERLAN. All rights reserved IKERLAN Polo Garaia C/ Goiru , 9 20500 Arrasate-Mondragón Tel.: 943 71 02 12 Fax: 943 79 69 44 IKERLAN Unidad de energía Parque Tecnológico de Álava, C/ Juan de la Cierva, 1 01510 Miñano Tel.: 945 29 70 32 Fax: 943 79 69 44 www.ikerlan.es ORONA IDeO - Innovation city Pol. Industrial Galarreta, Parcela 10.5, Edificio A3 20120 Hernani Tel.: 945 29 70 32 Fax: 943 79 69 44 IKERLAN Pº. J. Mª. Arizmendiarrieta, 2 20500 Arrasate-Mondragón Tel.: 943 71 24 00 Fax: 943 79 69 44 Questions? Email: [email protected] Thanks for your attention: