Java 8's new, Monadic Optional class is meant to resolve some common issues with
NullPointerExceptions. Instead, it's apparently caused some consternation among both new-school and old-school Java programmers -- for different reasons, of course. Hugues Johnson sums up the debate on his Java programming blog:
NullPointerExceptions] annoy developers more than I thought. It seems obvious that an object is really just a pointer and a pointer can point at nothing. Maybe it isn't any more? Perhaps the majority of computer science graduates this century never really learned about pointers since schools have gravitated toward high-level programming languages ...
The real catch with
Optional is the word class, notes Johnson, which may mislead some developers to expect a panacea, when what they're really getting is a wrapper: "if the goal is to avoid
NullPointerExceptions then this particular method is only useful if you already know you're assigning a non-null value, in which case why do you even need
Read more at Hugues Johnson's Java programming blog ...
This story, "Java 8's new Optional class: What's the point?" was originally published by Java Everywhere.