xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
- From: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
- To: Laurent Bihanic <laurent.bihanic AT atosorigin.com>, XOM-interest <XOM-interest AT lists.ibiblio.org>
- Subject: [XOM-interest] Automatic detach
- Date: Thu, 19 Sep 2002 10:33:03 -0400
At 10:33 AM +0200 9/19/02, Laurent Bihanic wrote:
- Automatic detach: Having to call detach when moving nodes from one place to another is realy cumbersome. A typical example is sorting a list of children. Why not support an automatic-detach mode so that programmer can move nodes freely?
It doesn't strike me as a huge burden on the programmer to have to detach a node first. I think two XOM principles are at issue here:
1. There's exactly one way to do it: since we need a detach method for non-moves, we should not duplicate it as part of insert.
2. Least surprise: would a developer be more surprised to find out that a node had been automatically detached when they forgot it had a parent and got the exception? Or would it be more surprising to later discover that a node had been detached? I'm not sure.
My thinking is that moves from one part of the tree to another are a relatively rare operation, so I'm not too concerned with optimizing them for the client. Calling detach() and then inserting is not that much harder than just inserting. I am worried about someone accidentally inserting something they didn't mean to detach. I've made this mistake myself more than once, and personally I prefer to get the exception so I see my error up front.
--
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo AT metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| XML in a Nutshell, 2nd Edition (O'Reilly, 2002) |
| http://www.cafeconleche.org/books/xian2/ |
| http://www.amazon.com/exec/obidos/ISBN%3D0596002920/cafeaulaitA/ |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.cafeconleche.org/ |
+----------------------------------+---------------------------------+
-
[XOM-interest] Firts impressions,
Laurent Bihanic, 09/19/2002
- Re: [XOM-interest] Firts impressions, Elliotte Rusty Harold, 09/19/2002
- [XOM-interest] ClassLoader issues, Elliotte Rusty Harold, 09/19/2002
- [XOM-interest] Code compactness vs instanceof, Elliotte Rusty Harold, 09/19/2002
-
[XOM-interest] CDATA handling,
Elliotte Rusty Harold, 09/19/2002
-
Re: [XOM-interest] CDATA handling,
John Cowan, 09/19/2002
- Re: [XOM-interest] CDATA handling, Elliotte Rusty Harold, 09/19/2002
-
Re: [XOM-interest] CDATA handling,
John Cowan, 09/19/2002
-
[XOM-interest] Document portions,
Elliotte Rusty Harold, 09/19/2002
- Re: [XOM-interest] Document portions, Laurent Bihanic, 09/20/2002
- [XOM-interest] Automatic detach, Elliotte Rusty Harold, 09/19/2002
-
[XOM-interest] Tree walking,
Elliotte Rusty Harold, 09/19/2002
-
Re: [XOM-interest] Tree walking,
Johannes Döbler, 09/19/2002
- Re: [XOM-interest] Tree walking, Elliotte Rusty Harold, 09/19/2002
-
Re: [XOM-interest] Tree walking,
Johannes Döbler, 09/19/2002
-
[XOM-interest] HTML Serializer,
Elliotte Rusty Harold, 09/19/2002
- Re: [XOM-interest] HTML Serializer, a student, 09/19/2002
- [XOM-interest] Element.getNamespacePrefix() vs Attribute.getPrefix(), Elliotte Rusty Harold, 09/19/2002
-
[XOM-interest] Element.add(),
Elliotte Rusty Harold, 09/19/2002
- Re: [XOM-interest] Element.add(), John Cowan, 09/19/2002
-
[XOM-interest] Node.howManyChildren(): getChildCount(),
Elliotte Rusty Harold, 09/19/2002
- Re: [XOM-interest] Node.howManyChildren(): getChildCount(), John Cowan, 09/19/2002
Archive powered by MHonArc 2.6.24.