[jdom-interest] Re: NoSuch*Exception

Dino Valente dino at 3dstockcharts.com
Wed Jun 28 09:38:40 PDT 2000


At 12:45 AM 6/29/00 +1000, Sirtaj Singh Kang wrote:
>On Wed, Jun 28, 2000 at 07:54:55AM -0400, Thomas M. Sasala wrote:
>> Sirtaj Singh Kang wrote:
>> 
>> 	If null is returned and it is not checked for,
>> then you will get a null pointer exception.  There's your
>> error ;)
>
>Not until it is dereferenced. Consider that it might be put into
>a database field or a collection. Then the effect of the error is
>discovered two or three steps away from where it is actually located,
>which is great if you enjoy debugging.
>
>(Please don't forget that this is probably by far the most common source
>of runtime errors in programming languages that don't have exceptions.)
>
>-Taj.
>
>Sirtaj S. Kang       taj at kde.org         ssk at physics.unimelb.edu.au
>Univ of Melbourne	The "gui" in "Penguin" is pronounced "K-D-E"
>_______________________________________________
>To control your jdom-interest membership:
>http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourho
st.com
>

I think you missed what people have been saying. Returning null should be
used in cases where optional elements are accessed. It appears people are
saying that is more convenient to check for null that using exception
handling (i.e run-time errors would not occur in these cases; OK you have
to make sure that you check for null). It is obvious to me we require both. 

It is curious to me that people readily accept that addChild from Element
returns `this' for convienience but adding a routine that returns null for
accessing elements seems to encounter a lot of resistance.

dino




More information about the jdom-interest mailing list