[jdom-interest] insertChild in Element

Brett McLaughlin brett.mclaughlin at lutris.com
Wed Aug 30 14:09:56 PDT 2000


"Rosen, Alex" wrote:
> 
> > You don't have to grab the "guts of an Element." You are grabbing a Java
> > structure that is universal (a List) and operating upon it. There's
> > nothing exposed about this.
> 
> The confusion is that, since you specify that actions on that List affect the Element,
> the natural assumption is that you're simply handing back a reference to the Element's
> internal List. This isn't the case, but it's the natural assumption, so people don't
> like it.
> 
> > You're inserting an Element - by definition, you want to affect the
> > internal implementation.
> 
> The problem here is the opposite assumption from before. Usually, when you ask for
> information about an object, you're given a static representation of that information.
> In most other APIs I've seen, if you get back a list-type data structure, changes to
> that structure don't have any effect. It feels very unnatural to me to get back a List,
> and then have changes to that List affect the Element. It makes sense once it's
> explained, but it will have to be explained over and over (as we've seen!)
> 
> > > It seems to me that the ability to insert a child into an Element at a
> > > particular location is behavior which belongs to the Element itself.  I
> > > would advocate adding this capability to Element.
> >
> > Seeing as we haven't heard this complaint from anyone else in 6 months,
> > I'm leary to add it. I think the line above is pretty simple to put in,
> > and makes a lot of sense. It's most of the reason we made the list of
> > children live, anyway.
> 
> Huh? Searching the archives for just the past 3 months, I found 4 different requests
> for this. Well, OK, in fact I found 4 different requests for the ability to insert an
> Element at a particular location, from people who didn't realize that you could do this
> by manipulating the List that's returned via getChildren(). This tells me that this is
> non-intuitive to many people (myself included). If this mechanism is kept as-is, it
> just needs to be *prominently documented* (perhaps in the JavaDoc for both the Element
> class itself, and for Element.addChild()).

Clarification: Nobody, once the method is explained, continued to
complain about how it works; I didn't mean that nobody didn't not
understand how to do it, I meant that once they did understand, everyone
was OK with it.

-Brett

> 
> --Alex
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

-- 
Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc. 
1200 Pacific Avenue, Suite 300 
Santa Cruz, CA 95060 USA 
http://www.lutris.com
http://www.enhydra.org



More information about the jdom-interest mailing list