Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The Null Object pattern is The Correct Answer (for Java like languages).

Java's Optional is a bad idea implemented badly made even more bad by bad usage.



Option is a takeoff of the Null Object pattern.

Option(null).map(str => str + "!").foreach(str => println(str)) is a noop.


Yeah, the Null Object Pattern is just optionals except you have to re-implement it each you need optional semantics.


No. They're opposites.

"...an object which implements the expected interface, but whose method body is empty. "

https://en.wikipedia.org/wiki/Null_Object_pattern




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: