Wednesday, September 16, 2009

One thing that I am unhappy with in the codebase that I am currently working on is the way the server piece generates the XML response.

The client piece, which shares code with the server piece, parses the XML into a response object.

The server piece does not use the response object used by the client code when generating the XML response. Rather, it uses another response object that internally has a StringBuffer (which could better have been a StringBuilder) in which the XML is built up, piece by piece with each call.

The first time I had to deal with that code was because it didn't properly encode the special XML characters, <, >, and &. It was also a pain to extend. And calling things out of order would cause invalid XML to get generated. This was the reason for a bug that was recently discovered in a rarely used codepath.

It would make so much more sense to build the response using the same response object used by the client code. And then, only turn it into XML when it's done and ready to be sent to the client.

On the other hand, it generally works well enough, and changing it is stupid busy-work that I don't want to be bothered with. And nobody else really cares about it anyhow.

No comments:

Post a Comment