[jdom-interest] Another plea for Interfaces and other musings

Rosen, Alex arosen at silverstream.com
Fri Mar 16 10:29:59 PST 2001


Why doesn't java.io.File use interfaces? Why do we write...

  File dir = new File(str);
  File child = new File(dir, filename);

...instead of...

  File dir = DefaultFileSystem.getInstance().createFile(str);
  File child = dir.createChild(filename);

...?

Because the former is clear, easy, and pleasant to write, while the latter is
less so.

I agree that interfaces would be more powerful, but I think we're all
underestimating how much they decrease ease of use, and just the aesthetics of
the API. JDOM was, as you said, created for easy reading and writing of XML.
DOM is powerful and uses interfaces, so that niche is already covered. But DOM
is really a pain to use for the 80% of the time when you just want to do the
simple thing. JDOM's purpose is to fill that (large) niche. Maybe there's room
for an API in between, that's more powerful than JDOM but easier to use than
DOM, but there are probably several axes on which to define "more powerful", of
which using interfaces is only one.

I think it's great that JDOM doesn't use interfaces.

--Alex



More information about the jdom-interest mailing list