I suggest to be careful with that, and I will most likely "-1" any global
changes in this area.
Otherwise we will face tons of IllegalArgumentExceptions instead of NPE.
Good example is working with objects in the GUI - during editing, some
objects may be in the partial state with lots of fields being null. Being
able to save and later read such partial states is important.
I just had a few cases like that recently, and I had to revert the behavior
to allow nulls.
As for jlint, I tried it at work and finally had to give up on using this
tool - it is way too picky.
Andrus
Holger Hoffstätte writes:
>
> hi,
>
> Catching illegal arguments and especially potential NPEs as early as
> possible is IMHO a Good Thing - don't let errors dribble down the layers
> until the bottom drops out somehwere else. Easiest & IMHO most obvious
> place to do at least some form of checking would be the setters, and have
> them throw an IllegalArgumentException("foo must not be null"), or
> whatever is appropriate. Classes without public accessors could have them
> protected/private I usually start with private and 'open up' as required).
>
> I've been looking at jlint's (admittedly extremely picky) reports some
> more and instead of randomly fixing potential NPEs with if-thens I'd like
> to have a more systematic approach that satisfies all and leads to an
> overall improvement by defect prevention. This should also improve bug
> reports & logging with more meaningful traces.
>
> Other thoughts or ideas?
>
> Holger
This archive was generated by hypermail 2.0.0 : Thu Dec 05 2002 - 10:36:54 EST