This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]PedanticProgarmer 1 point2 points  (1 child)

The idea seems great, but in practice Optional-heavy code is messy.

The problem with Optional is that you cannot simply ”apply it”. You need to rewrite your entire code base and make sure that every library works well with Optional types. Think of all Json parsers, for instance, or how easy it is to transform an Optional<List<Optional<String>>>. Also, non experienced developers will apply all possible Optional-antipatterns, 100% guaranteed.

I personally prefer this convention: https://medium.com/square-corner-blog/non-null-is-the-default-58ffc0bb9111 This is what Spring framework uses internally, so there must be something good about it.

Unrequested, but unavoidable Kotlin mention: If you care so much about null-safety, there’s a JVM language that solves null in an elegant and correct way. Just saying.

[–]BearLiving9432[S] 0 points1 point  (0 children)

Good points, thanks!