[jdom-interest] XMLOutputter
Alex Chaffee
guru at edamame.stinky.com
Fri Aug 4 07:05:43 PDT 2000
> Myself and about
> two or three others think that the way to go is to wrap all the
> formatting options in a separate class like the OutputFormat class
> in Xerces and the similar class in Enhydra Jason mentioned. Alex
> hates this idea, and wants to put all the formatting methods directly
> on XMLOutputter. I'm hesitant to move forward until we get this
> resolved.
>
> To me it just seems more convenient to wrap all the different options
> into one class and into single objects. It's a little more modular
> and somewhat easier to follow and learn if we don't store too much
> functionality in one class. Most importantly, a separate class makes
> it a lot easier to copy formatting options from one outputter to
> another or from a default set of options to an outputter. Alex I
> guess thinks this is an unnecessary level of indirection. One of the
> questions is whether anything except an outputter is ever likely to
> need formatting options, in which case the separation is a little
> more defensible.
How many options will actually be shared across outputters? As far as
I can see, zero. Remember, this is the XMLOutputter, the one class (or
superclass) that outputs a stream of angle-bracketed text. There are
other outputters, like DOMOutputter, that don't care about line
endings or indentation or pretty much any of the XMLOutputter
options. Why complicate DOMOutputter's life by forcing it to use an
OutputFormat class with ambiguous/undefined properties?
I repeat: OOP = data + behavior. The methods are the behavior. The
properties are the data. That's all we need here. Let's just define
the properties and move on.
My other, more pragmatic motivation for keeping the options inside the
object is it simplifies the API.
XMLOutputter o = new XMLOutputter(true, " ");
vs.
XMLOutputter o = new XMLOutputter( new XMLOutputFormat ( true, " ") );
--
Alex Chaffee mailto:alex at jguru.com
jGuru - Java News and FAQs http://www.jguru.com/alex/
Creator of Gamelan http://www.gamelan.com/
Founder of Purple Technology http://www.purpletech.com/
Curator of Stinky Art Collective http://www.stinky.com/
More information about the jdom-interest
mailing list