Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Functional Patterns with Java8 @Bucharest Java User Group


Published on

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.

Published in: Software
  • Login to see the comments

  • Be the first to like this

Functional Patterns with Java8 @Bucharest Java User Group

  1. 1. #DevoxxUK @victorrentea Functional Programming Patterns with Java 8 - live coding marathon - Victor Rentea IBM Lead Architect & Independent Trainer All the commits will be pushed to
  2. 2. Victor Rentea 13 years of Java Lead Architect at IBM Tech Team Lead and Consultant Clean Code Evangelist Moscow Paris London Krakow Vienna Sofia Casablanca Bucharest Belgrade Kiew Barcelona
  3. 3. @victorrentea  Spring  Hibernate  Clean Code, Architectures  Java 8, Design Patterns  Unit Testing  Java Performance  Scala & more... Independent Technical Trainer & Coach 1000+ devs 5 years tough clients:
  4. 4. @victorrentea Not Convinced? 5
  5. 5. Not Convinced? They were!
  6. 6. @victorrentea Hard-Core Switch
  7. 7. @victorrentea Hard-Core Switch
  8. 8. @victorrentea Let's CODE !! 9 I'll push everything here:
  9. 9. @victorrentea
  10. 10. @victorrentea The Clean Code Rules Applied to Java 8 11
  11. 11. @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
  12. 12. @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
  13. 13. @victorrentea Optional Instead: No NullableParameters Avoid Returning Null,Throw Ex … or return an Optional PS: don't be afraid of Orcs, Monads, or .flatMap 14
  14. 14. @victorrentea Passing-a-Block Pass logic to your function The Funeral of Template Method™ 15
  15. 15. @victorrentea Loan Pattern You work with a resource that is managed for you Decouples real logic from infra code 16
  16. 16. @victorrentea Execute Around Pattern Explicit AOP ~ Proxy™ or Decorator™ 17
  17. 17. @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
  18. 18. @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
  19. 19. @victorrentea Thank You! 20 Disclaimer: The use of ® or ™ is the slides is only anecdotic. So good we can ask more explanations after the Pizza What was that??
  20. 20. @victorrentea Thank You! 21 Disclaimer: The use of ® or ™ is the slides is only anecdotic. Let's Chat:
  21. 21. @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) Dissect some examples Basic Java8 Tutorial (Slow-motion) Mocking Kata TDD Kata Spring @Transactional