commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <blorit...@apache.org>
Subject Re: [lang] StringUtils.containsOnly
Date Thu, 26 Sep 2002 17:23:55 GMT
Stephen Colebourne wrote:
> 
> I go further than this - in my world a product like [lang] would never throw
> NPEs. If it did then that would be a bug. If null is a disallowed parameter
> then that should be checked and thrown as an IllegalArgumentException. But
> thats just my coding style.
> 
> Its probably a pity that we didn't agree a uniform approach to this, but its
> too late now. The priority is to document what we have correctly.
> 
> Stephen


I have to agree with you on both of your points Stephen.  NPE's are
indicative of something terribly wrong.  To me it is the Java equivalent
of the C++ pointer error.  At least with an IllegalArgumentException,
you know you skrewed up using the method.  An NPE could mean anything
from an illegal argument (see, IllegalArgumentException) to the method
is just completely foo-barred.  I reserve NPEs for things that are
foo-barred and IllegalArgumentExceptions for wrong arguments.

-- 

"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message