3 ms·
> Using null is fine. You probably don‘t need Optional. Using Optional is often „clever“ (=bad) overengineering. Option types are 8 years older than null (ML:
by Zababa 5y ago
> Using null is fine. You probably don‘t need Optional. Using Optional is often „clever“ (=bad) overengineering.
Option types are 8 years older than null (ML: 1973, null: 1965). There's nothing clever about it. It's simple to understand, and is an explicit wrapper around an object, while a pointer is an "implicit" pointer around an object. Option<Obj> is clear, you know that it can be something or nothing. Plain Obj is deceiving.
> Every NullPointerExceptipn my code ever caused was good, because it helped find an error state that had no acceptable default non error state alternative.
That's the point of option types and pattern matching, it can force you to handle both cases.