[jdom-interest] insertChild in Element

philip.nelson at omniresources.com philip.nelson at omniresources.com
Wed Aug 30 07:34:58 PDT 2000


 I disagree with this point.  I too didn't find the getChildren approach
instantly but now that I know it's there, I appreciate it for it's
simplicity.  The getChildren List interface is not exposing the guts of an
element as you suggest.  It was carefully constructed so that java
developers could use a familiar mechanism (the collections api) to
manipulate XML.  The DOM approach, because it doesn't cater to just java,
had to define it's own iterators, lists etc. and a programmer has to learn a
new one just for DOM.  With JDOM, it's just more java.

-----Original Message-----
From: James W. Howe
To: Brett McLaughlin
Cc: jdom-interest at jdom.org
Sent: 8/30/00 8:09 AM
snip...
There are a couple of things that bother me about the getChildren 
approach.  First, it violates the Law of Demeter.   You shouldn't have
to 
grab the guts of an Element in order to manipulate the Element.  You are

basically exposing the internal implementation of the Element object to
the 
outside world.  The second problem I have is that it violates the notion
of 
doing something Once And Only Once.  The odds are pretty good that there

will be more than one place where you might want to insert an element
and 
duplicating code is generally not a good idea.  Granted, the amount of
code 
you are duplicating is pretty small, but it is duplicated effort just
the 
same.

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.

James W. Howe				mailto:jwh at allencreek.com
Allen Creek Software, Inc.		pgpkey:
http://ic.net/~jwh/pgpkey.html		
Ann Arbor, MI  48103			

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



More information about the jdom-interest mailing list