Monday, July 25, 2011

Reasons to love geeks

For the geeks out there, here's something that you might find interesting.

Here are some of my favourites ("some" turned into "several" after some time :P ). They're from both the article and the forum thread it links to.

(I've highlighted the comments in red, while my own comments are in blue)

First, some simple ones:

//When I wrote this, only God and I understood what I was doing
//Now, God only knows

// drunk, fix later

// Magic. Do not touch.

//Code sanitized to protect the foolish.

return 12; // 12 is my lucky number

// TODO: Fix this. Fix what?
(I'm guessing that the "Fix what?" was added by a different person...)

// Author: If this code works, it was written by Paul DiLascia. If not then I don't know who wrote it.
(seems that this guy is famous)

// (c) 2000 Applied Magic, Inc.
// Unauthorized use punishable by torture, mutilation, and vivisection.

Some funny comments from frustrated programmers:

// John! If you'll svn remove this once more,
// I'll shut you, for God's sake!
// That piece of code is not “something strange”!
// That is THE AUTH VALIDATION.

/*
This isn't the right way to deal with this, but today is my last day, Ron
just spilled coffee on my desk, and I'm hungry, so this will have to do...
*/

Comments that go well with the actual code (my favourite type!):

} catch (PartInitException pie) {
// Mmm... pie
}

long long ago; /* in a galaxy far far away */
/* Halley's comment */
(like the comet!)

public boolean isDirty() {
//Why do you always go out and
return dirty;
}

if (/*you*/ $_GET['action']) { //celebrate

$you = live("free") or die("hard");
(I'm not sure about this one...it's really a valid code, I think.)

Catch (Exception e) {
//eat it
}

// some sport psychology
if (!focused)
Focus();

raise InvalidChild() # e.g. no legs

Then there are those who tell stories:

/* Emits a 7-Hz tone for 10 seconds.
True story: 7 Hz is the resonant frequency of a
chicken's skull cavity. This was determined
empirically in Australia, where a new factory
generating 7-Hz tones was located too close to a
chicken ranch: When the factory started up, all the
chickens died.
Your PC may not be able to emit a 7-Hz tone. */
(I love the story! :D )

int MyFunction()
{
// There once was a man named Dave
int Result = 0;
// Whose code just wouldn't behave
MyObject *Ptr = new MyObject();
// He left to go to a meetin'
Result = Ptr->DoSomething();
// And left his memory a leakin'
return Result;
}

// //3.4 JeK My manager promised me a lap dance if I can fix this release //3.5 JeK Still waiting for that dance from my manager //3.6 JeK My manager got changed, the new manager is hairy, dont want the dance anymore //3.7 Jek Got that dance, yuck! //
(Not sure whether this is a true story :P )

A "scary" one:

From the 2004 Windows leak,

__inline BOOL
SearchOneDirectory(
IN LPSTR Directory,
IN LPSTR FileToFind,
IN LPSTR SourceFullName,
IN LPSTR SourceFilePart,
OUT PBOOL FoundInTree
)
{
// // This was way too slow. Just say we didn't find the file. //
*FoundInTree = FALSE;
return(TRUE);
}

Ouch! So the file was actually there and Windows lied to us?!

Then this is not quite a comment but a goto label:

ICantBelieveImUsingAGoto:
(and a comment recommended this xkcd comic: GoTo (saying "Look out for the raptors.") )

An anecdote someone shared:

An old boss of mine was always going on about how we had to use our own products internally i.e. "Eat our own dog food..."

Many years later I found embedded in some source that a temporary coworker had done, every function he touched is tagged with:

/* NOT FIT FOR HUMAN CONSUMPTION */

Then there is the safety pig.

Some of these people love drawings...there are lots of comments about dragons (which seems to be a common joke to refer to an awful piece of code) and even a dragon drawing. But...the dragon comments get stale after a while.

No comments:

Post a Comment