~/talk

Do you use the Optional class as it should be?

Talkat jLove 2020 · 2020-12-04..12-05· [java]
slides:none on file

Claims that 65% misuse Optional, lists concrete anti‑patterns and replacements: avoid Optional as fields, constructor args, collection values; use Optional.empty and ofNullable for safe construction; prefer orElseGet for lazy defaults and orElseThrow (Java 10) for exceptions to prevent unnecessary DB/cache calls; use map/flatMap and Optional.stream to stay in the pipeline; prefer primitive Optionals (Int/Long/Double) to avoid boxing; notes isEmpty (Java 11) and ifPresentOrElse for clearer control flow and equals compares contained values.

AI-written summary · about

  1. 0:00Intro
  2. 1:18Presentation
  3. 8:30Use or else
  4. 13:28Exception
  5. 17:14If present
  6. 26:23Antipatterns
  7. 26:40Optional
  8. 27:34Serializable
  9. 28:05Option construction arguments
  10. 29:05Optional of nullable
  11. 30:03Optional of setters
  12. 31:52Make it simple
  13. 32:22Dont overuse also preferable
  14. 32:56Dont use return to collections
  15. 33:35Dont use avoid
  16. 34:08Performance and footprint
  17. 35:37Optional off
  18. 36:59Optional with numbers
  19. 37:49Optional with functional programming
  20. 38:40Optional with testing
  21. 40:02Reject the value
  22. 40:44Filter option
  23. 41:19Is present
  24. 42:01Transformation
  25. 42:58Map
  26. 43:16Math
  27. 44:36Flatmap
  28. 46:56Chaining
  29. 48:06OptionalStream
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.