The slides for the presentation I gave at Bucharest Java User Group. This session was the largest Romanian Java community meetup ever organized until now.
Functional Patterns with Java8 @Bucharest Java User Group
1. #DevoxxUK @victorrentea
Functional Programming
Patterns with Java 8
- live coding marathon -
Victor Rentea
IBM Lead Architect & Independent Trainer
victor.rentea@gmail.com
www.VictorRentea.ro
All the commits will be pushed to
https://github.com/victorrentea/functional-patterns-bjug-2018.git
2.
3. Victor Rentea
13 years of Java
Lead Architect at IBM
Tech Team Lead and Consultant
Clean Code Evangelist
victor.rentea@gmail.com www.VictorRentea.ro
Moscow Paris London Krakow Vienna Sofia Casablanca Bucharest Belgrade Kiew Barcelona
12. victorrentea.ro @victorrentea
Descriptive Names
Best Lambdas are fit, thin one-liners
Extract heavy lambdas into named ::methods
in the same class
in the item class
as static methods
-> {a-nonymous functions
12
Lambdas
13. victorrentea.ro @victorrentea
Stream Wrecks
1 usecase = 1 single chain of 30 function calls.
Don't do that !
We beg you !
We have children, families,…
Break them using explanatory variables
Small
Methods
Five Lines
13
18. victorrentea.ro @victorrentea
Avoid Checked Exceptions
java.util.function interfaces don't declare any throws
Which is good !
You must suffer if you work with non-Runtime Exceptions!
But if you insist:
- Define throwing functional interfaces
- Use libraries: jool, vavr...
18
19. victorrentea.ro @victorrentea
Type-specific Logic
switch
Switch Hunt Day®
Hope to find them all: JDD
Simplest to Read
1 switch = 1 method
case XX: return …
OOP
Extends is BAD
ONE Shot
Children90Movie
enum
Isolated Logic
In enum methods
Logic with Dependencies
Function references on enums
(bean passed as param)
19
22. victorrentea.ro @victorrentea
Thank You!
I'm available
a statement of seniority
I use both
hemispheres
Tough meetings?
Abused estimates?
Purpose of code:
1. Maintainable
-- Uncle Bob
Functional Party
Activist
Stay into
The Light
I brought you some
Motivational Stickers
In-house/remote
training or coaching?
What do You want us
to do the second hour?
(after the Pizza)
victorrentea.ro/vote.html
Dissect some examples
Basic Java8 Tutorial (Slow-motion)
Mocking Kata
TDD Kata
Spring @Transactional
victor.rentea@gmail.com
www.VictorRentea.ro