[jdom-interest] XMLOutputter observations
jhunter at xquery.com
Thu Feb 26 15:15:43 PST 2004
> 1. lines 59...: imports with * should be expanded (to eliminate
I just don't like expanding. There's no performance improvement with
expanding, it just takes up extra lines. For me, expanding is useful to
disambiguate collisions, otherwise I'm a * man all the way. I have
IntelliJ set to do a * as soon as there's two classes from a package.
I realize this is a religious issue. You can debate the point, but you
won't change anyone's mind.
> 2. skipTrialingWhite (line 1220) - spelling should be skipTrailingWhite
> - this method is private so it's not very important
Now that's funny. I fixed the name.
> 3. outputString (lines 524...) - these methods are perhaps in the wrong
> class. Although a clever convenience, they rather fatten the class with
> something that could have been separate (e.g. as a helper class or a
> derived class).
That point can be argued, but we're certainly not changing it after four
years. :-) And the counterpoint can be argued too, that it's an
XMLOutputter. Choose your output sink: stream, writer, or string.
> 4. I am uneasy that the output(Document doc, OutputStream out) method,
> which writes a whole document in one go, sits alongside a suite of other
> output methods that write a document part by part. These seem to me to
> be different ways of doing the same thing; perhaps therefore they should
> be done by different classes (?).
Again, not after four years. :-)
> 5. Eclipse points out some other redundant imports:
> XMLOutputter only needs
> import java.io.BufferedOutputStream;
> import java.io.BufferedWriter;
> import java.io.IOException;
> import java.io.OutputStream;
> import java.io.OutputStreamWriter;
> import java.io.StringWriter;
> import java.io.Writer;
> import java.util.List;
> import org.jdom.Attribute;
> import org.jdom.CDATA;
> import org.jdom.Comment;
> import org.jdom.DocType;
> import org.jdom.Document;
> import org.jdom.Element;
> import org.jdom.EntityRef;
> import org.jdom.Namespace;
> import org.jdom.ProcessingInstruction;
> import org.jdom.Text;
Much easier for humans to read, same effect on the compiler. :-)
Let us know if you find other issues.
More information about the jdom-interest