3 ms·
The problem with not checking for null is that it won't fail soon enough. null will get passed along until someone tries to call a method on it, at which point
by wtetzner 11y ago
The problem with not checking for null is that it won't fail soon enough. null will get passed along until someone tries to call a method on it, at which point you'll get a NullPointerException. But at that point you don't know where the null came from. It's better to fail early.
Lombok can help with this, with its @NonNull annotation, but that only helps so much.
- Dewie3 11y agoDo you assert that all object variables that cross an interface boundary are not null (`assert var != null`)?