by iainmerrick · 6y ago · 0 comments
I find them very useful. I don’t just want null pointer exceptions to be easy to debug, I want to avoid them completely in the first place.
Edit: You would want to implement these in your getters for fields that may return null
https://docs.oracle.com/javase/8/docs/api/java/util/Optional...
That's not to say the same thing is possible in C, but one _can_ go a long way with static analysis at least, and suspicion vs provability regarding pointer dereferences.
Hah! Annotations. They're tales told by idiots, full of sound and fury, signifying nothing.
But seriously, they're about as meaningful as reading the javadoc. At least Optional enforces the contract; it's just clunky.
Java annotations are better than Optional when you’re interoperating with Kotlin code, such as when you’re partway through converting a large codebase to Kotlin.