"I guess the developer wanted to make make sure that all his bases were covered!" wrote Ryan.

/// <summary>
/// Returns True if the input string is 
/// null, empty, "undefined", or "null".
/// </summary>
/// String to check /// Boolean public static bool IsEmpty(string s) {
	return string.IsNullOrEmpty(s) || s == "undefined" || s == "null"; }

 

Grahame wrote, "From the Javascript behind the download page (badly minified so that swapping eval for console.log reveals all the comments) of the 2011 Census of a certain country. Nice of them to document their naffness!"

//----------------------------------------------------------------------------------------------------------------
// Function: guidGenerator
// Description:returns a pseudo-random GUID
//This is appended to a url for 2 reasons
//1. to make the URL unique, so that the browser always gets it and doesn't use a cached version
//2. to make a URL look like its got a unique key, in a naive attempt to fool a not-so-wily hacker
//into thinking they can't download a datapack directly if they know the URL pattern, because they
//need a unique key.
//----------------------------------------------------------------------------------------------------------------
function guidGenerator() {
    var S4 = function() {
       return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
    };
    return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
}

 

"I grabbed latest from our codebase the other day and ran across a method that I didn't recognize. It had a comment block above, with what I believe is the best comment I've ever seen," wrote Nathan

 

"I found this snippet of code when debugging an application developed by the software team I'm a part of," writes Goatie, " I happen to know this functionality was written by my boss. He has a habit of using rather unusual variable names."

    Case "SecretSquirrel"
                c_IsMemberOfSecretSquirrelClub = e.Result
                c_SecretSquirrelCommand.RaiseCanExecuteChanged()
        End Select
    End Sub

    Public ReadOnly Property CurrentSecretSquirrelShowiness As Boolean
        Get
            Return c_CurrentSecretSquirrelShowiness
        End Get
    End Property

 

"I was recently tasked to fix some 508 compliance issues in a C#, ASP.NET application at the company I work for," writes Dan Johnson, "I was warned that the code may be a little, let's say, not well matured. That's fine, I've seen bad. Architecture, style and good practices problems all aside, I began to see comments throughout the code like this:"

//don't do this -- too slow when there are many rows in the grid
//return;
//update:  actually it's pretty fast now - use it if desired and 
//don't rebuild the grid on the client because using setTargetURL DOES NOT WORK
//go ahead and do it - we're not using links for the app names now

 

"The frightening thing is that I'm not sure if there was more than a single developer on this project or not. At the time it was originally built and maintained, our department operated on a one-person-per-project rule."

"I was working on Java/Delphi code and I could not believe my eyes when I found this comment," writes Vladamir P.

    /** java uses BigIndian, Delphi uses little indian, while the
      two co-exist, need to convert back and forth when reading
      data in. */

"At first, I thought that maybe it was an isolated typo, that is until I looked further into the code..."

  /** convert from big indian to little indian: Remove when not using
      legacy databases or Delphi code.*/

    private final boolean doIndianConversion()

 

"I work at a medium large IT company with a handful of developers. A few months ago one of my colleagues left. He was a developer-slash-designer and was the only on in the company who used a Mac computer (a disused old Mac Mini)," writes Jan V., "His design skills were significantly better than his developing talents. Not that he was a bad developer, but he always had a ... let's say ... his own perspective on things, including his way of setting a debug flag."

Class Controller_WTF Extends Controller_Base
{
	function index()
	{
		$registry = Registry::getInstance();
		if($_SERVER['HTTP_USER_AGENT']=="Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; nl-nl) AppleWebKit/533.19.4 ".
                                                "(KHTML, like Gecko) Version/4.1.3 Safari/533.19.4"
		{
			$debug = true;
		}
	...
	}
...
}
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!