directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trustin Lee <trus...@gmail.com>
Subject Re: [OT] How best to respond to null arguments?
Date Thu, 01 Sep 2005 00:02:53 GMT
Hi Alex,

I usually choose option #2. Because null argument is usually unacceptable at 
many situations.

But also consider replacing null argument with the default value silently. 
:)

I don't recommend using assertion where there's an interaction with users 
because it can be disabled by them.

Trustin

2005/9/1, Alex Karasulu <aok123@bellsouth.net>:
> 
> 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
> 
> 


-- 
what we call human nature is actually human habit
--
http://gleamynode.net/

Mime
View raw message