[jdom-interest] JDOM JSR

Alex Rosen arosen at silverstream.com
Thu May 17 08:01:22 PDT 2001

I think that dom4j is better if you have to subclass, while JDOM is better if
you don't.

(I'm sure there are people (particularly the authors) who will disagree with
each of those statements.)

I like to think of the java.io.File class as a very JDOM-like class. There's a
reason we say:

  File parent = new File(filepath);
  File child = new File(parent, "aaa.txt");

rather than:

  FileSystem fs = FileSystem.getDefaultFileSystem();
  File parent = fs.getFile(filepath);
  File child = fs.getFile(parent, "aaa.txt");

On the other hand, nobody ever (or rarely) subclasses File. I don't know if
that's because it's hard to do, or if it just doesn't happen to be necessary
very often. But the designers of java.io.File desided to make the common case
(no subclassing) easier, and the less common case (subclassing) harder. While
it certainly seems that people want to subclass XML objects more than file
objects, I'm still certain that 80% or more of the uses of XML are just reading
and writing it, without the need for subclasses. So this is still a valid
design decision. You just never hear from the 80% of the JDOM users that don't
need subclasses, who are happy with the current design, because they don't have
anything to complain about.

Alex Rosen
SilverStream Software

More information about the jdom-interest mailing list