[jdom-interest] getChildTextNormalize()

Kyle F. Downey kdowney at amberarcher.com
Wed Oct 3 12:58:20 PDT 2001


> JDOM used to work this way, and after *quite* a bit of discussion, we
> changed it. There are many of APIs that return null to indicate that the
> item doesn't exist (that is the meaning of null, after all). E.g. the Map
> interface in Java collections. The discussion was in June and July 2000
> (wow, that was a long time ago...) if you want to take a look.

Understood. However, just because Sun does it one way, does not
necessarily make it correct--not by a long shot! I present to you
URL.setURLStreamHandlerFactory(URLStreamHandlerFactory fac) as Exhibit A
in that case. ;-)

APIs that rely on returning null to signify "not found" rely on
documentation & the good intentions of the API's users. Good, defensive
programming usually argues against anything that relies on the coder
making extra checks every time a method is called to ensure correct
behavior in the most common cases.

If there's a long history to this, I assume I will not move any hearts or
minds here. But I thought to give it a shot before this becomes set in
stone as part of the standard Java APIs....

--kd




More information about the jdom-interest mailing list