[jdom-interest] XMLOutputter naming questions

Elliotte Rusty Harold elharo at metalab.unc.edu
Mon Oct 2 04:51:34 PDT 2000

At 12:34 PM -0700 10/1/00, Jason Hunter wrote:
>>  Just read TODO.txt: "Write
>>  XMLOutputter.serialize(doc/elem/comment/doctype/entity/pi/attrib).
>>  Have
>>  these methods replace getSerializedForm().  Going this way allows
>>  tweaks to the XMLOutputter behavior before serialization."
>>  I think "serialize" is the wrong word; "output" is better for this,
>>  since it's consistent with the name of the object, isn't confused with
>>  other meanings of "serialize," etc.
>Elliotte, are you still around?  I believe you chose the name
>getSerializedForm() initially.  Do you want to justify the use of

Yes I'm still around. I've been playing around with trying to get 
namespace declarations into JDOM. I've got them working in Element, 
but making them work in XMLOutputter is the trickiest part so I've 
been waiting to let Alex's latest batch of changes make their way 
through before I dig into that code again.

To address the specific question, now that I think about it I really 
dislike both the output() and outputString() names for these cases. 
Nothing here is being output. Output is when data moves from memory 
to some external target, be it a disk or a network connection or a 
console. That's not happening here. Using the word "output" for a 
method that builds a string in memory is misleading.

I am not wedded to getSerializedForm() though. It was just what I 
came up with on the spur of the moment to distinguish it from 
toString(). I probably had seen a similarly named method in some 
other API somewhere, and I was certainly thinking of DOM terminology 
of serializing an in-memory instance of an XML document onto a stream 
which these methods are no longer doing.

There are many other possibilities, however. We could call these 
methods getStringForm(), buildString(), or something else. It 
certainly doesn't need to include the word "serialized", and you're 
right that this is also potentially misleading.

| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
|                  The XML Bible (IDG Books, 1999)                   |
|              http://metalab.unc.edu/xml/books/bible/               |
|   http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/   |
|  Read Cafe au Lait for Java News:  http://metalab.unc.edu/javafaq/ |
|  Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/     |

More information about the jdom-interest mailing list