"I found a schizophrenic comment that either intentionally or unintentionally happens to be a haiku," wrote Ben Vanik, "svn blame says this single line is the work of 3 different people across 3 years of coding."

// should delete the temp files here, no cannot because, we havent read it in yet!

 

"I'm modifying some firmware for a product that has a serial connection," Fahrzin Hemmati writes, "this was found in the method that translates the incoming data into useful bytes."

//Clear it, or it, smack it, flip it, rub it down 
//(Oh nooooo...)		
mem[iAddress] &= ucClearBit;
mem[iAddress] |= ucAssignBit;

 

"How do you feel when you see this code on the first day of your job?" wonders Ritesh

#define EIGHTY 256

 

"I found this piece of java code in our corporate directory," writes Peter S, "two of our JUnit test classes end in this method. I do not know if these were intended phuns/easter eggs."

@Test
public void testNothing() {
   assertTrue("Assert just to keep JUnit happy!", true); }

 

"When debuging some client code I came across this," wrote Blair, "tmpnum8 was wrong. Now I just have to figure out what all the other tmpnums are..."

tmpnum6 = tmpnum2 + tmpnum * (tmpnum4 - tmpnum2);
tmpnum7 = tmpnum3 + tmpnum * (tmpnum5 - tmpnum3);
tmpnum8 = tmpnum6 + tmpnum1 * (tmpnum7 - tmpnum6);

 

"The previous developer on our OBIEE environment had some interesting ways of developing queries," wrote Bart, "not only did he not know about Oracle functions like NVL(), requiring him to write everything using lengthy CASE statements, also using joins seemed out of the question. This code is een excerpt from a _large_ view unioning large blocks of codes like this to each other. I also like how he did code reuse, he copied large pieces of code to different views."

SELECT decode(authorization_kd,
 3,3,    4,3,    6,3,    7,3,    34,3,
 55,3,   57,3,   58,3,   24,4,   10,4,
 11,4,   21,4,   71,4,   36,4,   37,4,
 38,4,   13,4,   14,4,   84,4,   53,4,
 15,4,   33,4,   31,4,   32,4,   09,5,
 12,6,   52,6,   54,7,   19,8,   20,8,
 79,8,   99,8,   9) process_kd
FROM   dossier
WHERE  authorization_kd NOT IN (1, 30, 35, 85, 86, 87, 16, 17, 18)

 

"Starting work in a project is always a kind of challenge," notes Wiadran, "if the project has been developed for years and written mostly in ASP classic... it might become a nightmare. Nevertheless, projects developed for years have some bright side as well: parts of not-understandable code and commentaries."

For intI = 7450 To 7450
'Now lets go and create the f*&ker
   ... snip...
Next 

 

Jimmi found yet another wrapper for the illusive '!' operator.

private static bool InvertBool(bool org)
{
	bool returnValue = false;
	if (org)
	{
		returnValue = false;
	}
	if (!org)
	{
		returnValue = true;
	}

	return returnValue;            
}

 

"How many naming conventions can you find in the following line of code?" writes Malcom

StandardResponse UnSubscribeNewsletterUserAccount(
  string opTinGUID,string email, 
  string sellingRegion, string source, 
  DateTime opt_out_date, string strevent, string reason);

 

"While diving through some old code I'm maintaining, I found this jewel," Frank writes from the Submit-To-WTF Visual Studio Add-In, "Not only is this snippet a part of a rather intricate XML merge system, but it also merges the XML by string operations. To add insult to injury, the XML is not possible to define in a schema (as elements have to occur in certain patterns, while the name of the only valid elements in the XML 'schema' is either FLD or REC. The types of REC depends on the NAME attribute, and it is the NAME attribute that ultimately decides the order of the REC elements in the document. In other words, a truly fubar mess."

// Dear future developer(s): 
// I have no idea who actually came up with such a glorious violation of the 
// XML definition, but legacy systems being legacy systems means that we can't 
// switch this. 
// I feel for you, young padawan; I'd rahter kiss a wookie than mess with this.
if (line.IndexOf("REC NAME=\"Hovednivå\"") <= -1) continue;