[jdom-interest] detach() [eg]
Elliotte Rusty Harold
elharo at metalab.unc.edu
Mon Apr 30 07:07:15 PDT 2001
At 6:00 PM -0700 4/29/01, Jason Hunter wrote:
>> That's secondary to me at this point. I am
>> saying, though, that I think detach() on an Element would make me think it
>> detaches an element from the object detach() is being invoked on.
>
>Luckily detach() takes no parameters so if that's your inclination (note
>it's not my inclination) then you'll have to realize it doesn't work
>that way.
>
I think Brett's correct here. The way I explain it to my students is that
the customary order in OOP is
subject.verb(object)
element.detach() violates that common understanding, especially since
detach is not a reflexive verb.
I really see no need for detach() anymore. I think that
parent.removeContent(child) is all that's necessary; and detach() as
currently written is just plain confusing. If we absolutely must have
that bit of syntax sugar, then the name should be changed to a verb
that does commonly operate on it's subject, like element.breakAway()
or some such; but I really don't think we need it.
And of course removing detach() totally eliminates the problems of
clients unintentionally detaching the root element of a document.
--
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| The XML Bible (IDG Books, 1999) |
| http://metalab.unc.edu/xml/books/bible/ |
| http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/ |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://metalab.unc.edu/javafaq/ |
| Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/ |
+----------------------------------+---------------------------------+
More information about the jdom-interest
mailing list