[jdom-interest] NoSuch*Exceptions in JDOM

Brett McLaughlin brett.mclaughlin at lutris.com
Mon Jun 19 09:28:44 PDT 2000


Jim Rudnicki wrote:
> 
> Lurking here I notice everyone dividing into two camps. Let me offer a third
> direction.
> 
> Any function using the return value to return error codes I accept as bad
> design.  I thought we all learned this long ago.  A section from "Writing
> Solid Code" burned in my memory (but looked up, p91):
> 
>   "Don't use confusing dual purpose return values--each output should
> represent exactly one data type.  Make it hard to ignore important details
> by making them explicit in the design."

Jim to the rescue!!! Thanks - I appreciate the reference, and I think
you have, among other suggestions, pointed out one of the fundamental
differences between Java and C - we don't return -1 (except indexOf ....
grr...) to indicate errors, as that is bad form ;-)

> 
> >From this, the correct design choice is:
> 1. So getChild() should always return a child or throw an exception.  Null
> is not a child.  Exceptions are hard to ignore.  null is too easy to ignore.
> 2. If the program does not know if a child is present, it should, must, or
> ought to be testing with:
> boolean hasChild( String s );
> 
> Alas, there is no hasChild() ?

There's not, but on the strength of this email, I'm willing to put one
in.

-Brett

> 
> nite,
> Jim
> 
> I
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

-- 
Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc. 
1200 Pacific Avenue, Suite 300 
Santa Cruz, CA 95060 USA 
http://www.lutris.com
http://www.enhydra.org



More information about the jdom-interest mailing list