Re:Java 8’s new Optional type doesn't solve anything
by bakhy on Wednesday October 28, 2015 @12:49PM
(#10465617)
i understand, and agree. i would personally, though, avoid adding it, and add attributes for the same purpose instead. just as the article suggests... it achieves the same without introducing a new class, thus also remaining backwards compatible.
Yes, it's not ideal, it's still a flaw that should be caught at compile-time, but it's not a big real-world problem, as returning null by accident instead of an option is a pretty rare bug.
The much more common bug (you didn't realize no return value was a case), the Option is a good counter to.
No, it's not a perfect solution, but it's not useless either.