I don't have experience of JDOM so I am not going to judge it
prematurely.

Just want to discuss with you about the argument of Interface- and
Class-based design.

Maybe scalability, performance is more about the high-level design, but
Andy Clark was absolutely right about the extensibility, flexibility of
the interface over class.

DOM is a specification which can be implemented in multiple languages.
So interface-based design is very natural for this purpose. One beauty
of interface-based design is you can swap the implementation without
breaking the existing code. So you can develop your application against
those interface, with the peace of mind that it can run without any
problem on another implementation. You focus on your application, other
people compete with the implementation. 

Class hierarchy is simpler to understand because it's more "solid" or
"material" for novice. You may also be able to use sub-classing to
achieve some flexibility. But inheritance has fundamental limitations.
Once you subclass a API class, you are tied to that class for ever. Any
new changes made to the base class may break your code. While with
interface, you can completely replace with a new implementation, but all
existing code working with the interface will be guaranteed to stay
working, enjoying whatever benefit the new implementation brings. This
is especially important for API classes.

Josh Bloch made an excellent example in his Collections Framework
design. In his Effective Java book, there are also some good stuff about
the potential danger of class-based API design.

Personally, I don't have any problem understanding DOM's interface. I am
especially happy that with JAXP, my code can be completely decoupled
from any particular XML parser. I can write my code against JAXP, DOM,
and SAX with peace of mind that whenever a better JAXP-compliant XML
parser appears, I can immediately jump on the wagon. With JDOM, can I do
the same thing? 

Thanks.
Li

-----Original Message-----
From: Elliotte Rusty Harold [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 31, 2001 7:10 AM
To: [EMAIL PROTECTED]
Subject: Re: renaming elements


At 11:31 AM +0900 7/30/01, Andy Clark wrote:


>There are a handful of different tree models out there in Java.
>However, be *very* careful about what you pick and for what
>reason. JDOM is based on a class hierarchy instead of interfaces
>so it limits the extensibility and scalability of any application
>written using it. Once you get past the learning curve for DOM,
>you may find that you like it. Or not. But either way, make an
>educated decision.
>

I've never quite understood the objection to the class hierarchy in JDOM
as opposed to interfaces. Interfaces are perhaps marginally more
extensible, but I've seen through experience that the vast majority of
developers don't need the extra flexibility of interfaces, ever,
especially when you remember that subclassing is still an option in
JDOM's class-based hierarchy. Those few developers who do need the extra
flexibility of interfaces, don't need it most of the time. 

I would completely disagree that interfaces are somehow more scalable. I
see no evidence of that at all. Different implementations of DOM may be
more or less scalable than JDOM (I've certainly seen ones that are less)
just as different betas of JDOM have been more or less scalable than
each other. The latest beta 7 is a huge improvement on previous betas in
this area, which were already much more scalable than Xerces 1. 

Most importantly, most developers find interface-based designs to be
confusing and hard to grasp. Class-based designs are much easier to
follow, understand, and use. The participants in this mailing list are
not representative of the DOM/JDOM user base. I teach this stuff
frequently, and when I teach both DOM and JDOM to a novice audience,
most students immediately grasp JDOM but have a really hard time coming
to grips with DOM. When I teach JDOM to a DOM-literate audience, the
sighs of relief are audible. Human factors are a very important aspect
of API design, and one that has been almost completely ignored in the
design of DOM. 

There are some real criticisms of JDOM, and some reasons one might
prefer DOM for some more complex applications. However, using interfaces
instead of classes is not one of those reasons.  
-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | [EMAIL PROTECTED] | Writer/Programmer |
+-----------------------+------------------------+-------------------+ 
|          The XML Bible, 2nd Edition (Hungry Minds, 2001)           |
|              http://www.ibiblio.org/xml/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      | 
|  Read Cafe con Leche for XML News: http://www.ibiblio.org/xml/     |
+----------------------------------+---------------------------------+

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to