[jdom-interest] JDOM JSR

Richard Baldwin baldwin at austin.cc.tx.us
Fri May 18 12:56:23 PDT 2001


It is a serious use case if you want to avoid having to
invoke instanceof in a switch statement followed by a
cast just to discover and convert to the type of the
object before invoking a common method such as
getParent(). That is the primary benefit of polymorphic
behavior based on interfaces. It eliminates the
requirement to discover the true type of the object
before invoking a common mathod (such as invoking the
add() method on a Collection object without being
concerned about its true type). 

But, having read your servlets book, I'm confident that
you already know all of that and must have decided that
the convenience of polymorphic behavior is more than
offset by some other factors.

I'm sure that you have given all of these matters an
enormous amount of thought, and I appreciate that. 
I'll be happy to have access to JDOM even if its design
is different from what I may have done under similar
circumstances.

Dick Baldwin
============

Jason Hunter wrote:
> 
> Richard Baldwin wrote:
> >
> > For example, I would like to be able to iterate on the
> > list returned by getMixedContent() and invoke
> > getParent() on any item in that list without having to
> > worry about the actual type of the object.
> 
> That can't be a serious use case.  getParent() on every item would be
> identical.  What's a more realistic use case you've encountered?
> 
> Some background, covered before but I'll hit it again:
> 
> The problem is that the number of methods which JDOM objects have in
> common or could have in common is close to zero.  Therefore to create a
> Node we have to either allow methods which don't make sense for all
> objects (like getMixedContent() on Attribute) or we have Node as really
> just a marker interface.  Myself, I don't want to see non-sensical
> methods because that's one of the core problems with DOM.  And I don't
> see sufficient value for Node as just a marker interface for reasons
> enumerated before.
> 
> Some people propose to get more methods into Node by restricting the set
> of JDOM objects that would qualify as Nodes.  That tends to come at the
> cost of other people's desire for everything in JDOM to be a Node.
> 
> -jh-

-- 
=========================================================
Richard G. Baldwin (Dick Baldwin)
Home of Baldwin's on-line Java Tutorials
http://www.geocities.com/Athens/7077/scoop/onjava.html

Professor of Computer Studies
Austin Community College
(512) 223-4758 or (512) 250-8682
mailto:baldwin.richard at iname.com  
http://www2.austin.cc.tx.us/baldwin/
---------------------------------------------------------



More information about the jdom-interest mailing list