Java best practices summary

This document is an extension of the Software engineering best practices summary, dedicated to Java-specific issues.


  • Use the LocalDateTime API (LocalDate, LocalTime, LocalDateTime, etc.) instead of other solutions (like JodaTime)


  • Wherever it makes sense, use Java 8’s streams – they are usually more readable than classic for-loops
  • Every function call after .stream() should start from a new line
  • If an anonymous function has more than one line, consider extracting it into a separate method


  • Prefer .orElse() instead of .isPresent()