[jdom-interest] detach() [eg]

philip.nelson at omniresources.com philip.nelson at omniresources.com
Sun Apr 22 13:44:28 PDT 2001


> I agree with Jason that adding an extra exception to detach() 
> complicates
> all usage:
> 
>     childElement.detach();
> 
> If we want to support:
> 
>     rootElement.detach();
> 
> then what's the difference to the user between a well-formed 
> document that
> contains unintended "placeholder" content, and a document 
> with a null root
> element?

Not much!

<snip> 
> Null will also fail faster.  It will very likely result in 
> NPE if the user
> fails to detect it first.  In comparison, "placeholder" will likely
> pass-through without exception if the user fails to detect it 
> (or misspells
> it), in which case the user'd never know until they saw 
> "placeholder" in
> their output.

Right, and this could be days after the fact.  I just dislike
NullPointerExceptions because it's never exactly clear where they come from.
That's why I like a more explicit exception.  The placeholder text sort of
gives you that, but an exception is even clearer and faster as you point
out.



More information about the jdom-interest mailing list