Are you using Java8 Lambdas & Streams in your core business logic? Then you might be having this strange feeling that it’s not Java anymore: at times it’s cryptic, barely readable.. This was the topic of the workshop with the same name that I held at VoxxedDays Bucharest 2017. These are the slides backing the that workshop.
As a summary, the materials walk through the functional features of Java8, adding details along the way about how we can keep the code clean as we embrace the Java 8 features.
The entire desktop screencast + voice it's on youtube, here: https://youtu.be/uH9A37k2QkU
2. VictorRentea.ro
Clean Code Evangelist
International Speaker Spring and
Clean Code, Design Patterns ( )
TDD, Coding Dojos
Java Performance
many more:
Victor Rentea, PhD(CS)
Consultant, Technical Lead
Lead Architect for major client at IBM Romania
Night Job :
Freelance Trainer & Coach
victorrentea@gmail.com www.victorrentea.ro@victorrentea
2
3. VictorRentea.ro
They are cool
Expressive code
- .filter(Order::isActive)
Concise code (½ lines?)
Cryptic? Hard to read?
- What guidelines to follow ?
Why Lambdas ?
3
4. VictorRentea.ro
Which λ to use in enterprise Java apps ?
- Readable, maintainable
- vs Java7
-
Questionnaire-based
- Java8 features in examples from production
- For Java developers of any exp level (min 3 months of Java8 hands-on)
- Wanna submit you answer? Thank you !! : http://bit.ly/2dFf2fi
My own little
Clean Lambdas Study
4
6. VictorRentea.ro
// Cool Class Diagram
[Order|id:Long;creationDate;paymentMeth
od;status:Status;totalPrice:BigDecimal]-
orderLines*>[OrderLine|count:int;isSpecial
Offer]
[OrderLine]-product>[Product|name]
[Audit|action;date;user;modifiedField]
Before we start: configure your IDE to suggest static imports of:
java.util.stream.Collectors.* and java.util.Comparator.comparing
In Eclipse: Preferences > type “favo” > Favorites > New Type & New Member
Our Domain Model
6
65. VictorRentea.ro
Resources
Java 8 in Action by Raoul-Gabriel Urma, Mario Fusco, Alan Mycroft, 2015
https://blog.jetbrains.com/idea/2016/07/java-8-top-tips/
https://github.com/jOOQ/jOOL
Clean Code by Robert C. Martin
https://zeroturnaround.com/rebellabs/java-8-best-practices-cheat-sheet/
https://www.journeytomastery.net/2015/03/22/clean-code-and-java-8/
Curious about Java9: https://bentolor.github.io/java9-in-action/
65