directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Karasulu <aok...@bellsouth.net>
Subject [OT] How best to respond to null arguments?
Date Wed, 31 Aug 2005 18:23:46 GMT
Hi all,

I was playing again with my very many split personalities when I 
realized one likes to throw NullPointerExceptions after checking if an 
argument is null while another likes to throw IllegalArgumentExceptions 
since null is value the argument can take.   Yet another personality 
does not care and figures a NPE will result anyway when the null 
argument is referenced so why bother.

Question: How best to respond to null arguments?

Option #1: Ignore it and let a NPE result on its own
Option #2: Test to see if arg is null early and throw a descriptive NPE
Option #3: Test to see if arg is null early and throw a descriptive IAE

Which sounds best?

Alex


Mime
View raw message