Wednesday, December 01, 2004

The Daily WTF

Check it out at http://thedailywtf.com/forums.aspx. RSS feed at http://thedailywtf.com/rss.aspx?ForumID=12&Mode=0

Describes itself as "Curious Perversions in Information Technology". Everyday they post a new coding horror. These (most) are taken from real world code which people have come across. Covers a whole range of languages.

As a sampler, check out today's post...

------------------------------------------------------------------------------------
The .NET developers out there have likely heard that using a StringBuilder is a much better practice than string concatenation. Something about strings being immutable and creating new strings in memory for every concatenation. But, I'm not sure that this (as found by Andrey Shchekin) is what they had in mind ...


public override string getClassVersion() {
return
new StringBuffer().append(
new StringBuffer().append(
new StringBuffer().append(
new StringBuffer().append(
new StringBuffer().append(
new StringBuffer().append(
new StringBuffer().append(
new StringBuffer().append(
new StringBuffer().append("V0.01")
.append(", native: ibfs32.dll(").ToString())
.append(DotNetAdapter.getToken(this.mainVersionBuffer.ToString(), 2)).ToString())
.append(") [type").ToString())
.append(this.portType).ToString())
.append(":").ToString())
.append(DotNetAdapter.getToken(this.typeVersionBuffer.ToString(), 0xff)).ToString())
.append("](").ToString())
.append(DotNetAdapter.getToken(this.typeVersionBuffer.ToString(), 2)).ToString())
.append(")").ToString();
}

Note, that it is J#, StringBuffer and StringBuilder are the same thing.

No comments: