[jdom-interest] detach() [eg]

Joseph Bowbeer jozart at csi.com
Sun Apr 22 13:07:39 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?

Null is more explicit, in that nothing represents "nothing" better than
"null".  In comparison, "placeholder" is arbitrary.  The user can misspell
it and the program will still compile.

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.

Note: If we do want to support root.detach() then we should also support:

    doc = new Document();

-or-

    doc = new Document(null);


--
Joe Bowbeer

PS - Most of the Document constructors call overridable methods.  This is
likely to cause problems with subclasses.






More information about the jdom-interest mailing list