null
is often ambiguous. Was the field uninitialized yet or it just has no value?
It's often better to have some predefined constant for uninitialized / irrelevant fields.
Even better is to have one class have only one responsibility. Methods like getFlightSpeed()
should not be inherited, rather come from implementing an interface (methods like getDeathDate()
, though, should have a predefined constant returned when Animal
is still alive).
As brought by google-guava docs:
Doug Lea (author of java.util.concurrent
package) said that Null s**ks
.
Also sir C. A. R. Hoare, inventor of the null
reference said: I call it my billion-dollar mistake
.
That's some wide shoulder to lay upon.