Bewildering Code

Just sit back and ponder this code for a while:

StringBuilder query = new StringBuilder();
query.Append(string.Format("//{0}[", "ArrayOf" + Result.Name));

So it's creating a StringBuilder...but then it decides to use a string.Format call instead of a couple of Append calls on the then there's a concatenation within the Format call.

The hurts so bad!

Now, there's more code to this story (i.e. there's a good reason to use StringBuilder), but for all that is good in this world, why not just do it this way:

StringBuilder query = new StringBuilder();

Now, to be fair, I'm not sure that this would actually perform better. Tests would have to verify that. But I'm guessing that it would, and frankly it just reads better this way.

* Posted at 11.01.2007 07:50:34 AM CST | Link *

Blog History