Tuesday, May 7, 2013

Funny comments

Recently while browsing, I encountered a question at stakoverflow which asks for “What is the best comment in source code you have ever encountered?". It has a long list of funny list. I am just copying few of my favorite.
Exception up = new Exception("Something is really wrong.");
throw up;  //ha ha
// Autogenerated, do not edit. All changes will be undone.
// sometimes I believe compiler ignores all my comments
// I dedicate all this code, all my work, to my wife, Darlene, who will
// have to support me and our three children and the dog once it gets
// released into the public.
// drunk, fix later
// Magic. Do not touch.
#define TRUE FALSE //Happy debugging suckers
// I'm sorry.
return 1; # returns 1
/* This is O(scary), but seems quick enough in practice. */
Catch (Exception e) {
 //who cares?
 * Always returns true.
public boolean isAvailable() {
    return false;
 * You may think you know what the following code does.
 * But you dont. Trust me.
 * Fiddle with it, and youll spend many a sleepless
 * night cursing the moment you thought youd be clever
 * enough to "optimize" the code below.
 * Now close this file and go play with something else.
try {

} finally { // should never happen

const int TEN=10; // As if the value of 10 will fluctuate...
long long ago; /* in a galaxy far far away */
//This code sucks, you know it and I know it. 
//Move on and call me an idiot later.
// If this comment is removed the program will blow up
double penetration; // ouch
// I don't know why I need this, but it stops the people being upside-down

x = -x;
// I am not sure if we need this, but too scared to delete.
# To understand recursion, see the bottom of this file

At the bottom of the file:
# To understand recursion, see the top of this file
// I am not responsible of this code.
// They made me write it, against my will.
/* Please work */
//private instance variable for storing age
public static int age;
/* You are not meant to understand this */
//I am not sure why this works but it fixes the problem.
// I will give you two of my seventy-two virgins if you can fix this.
// no comments for you
// it was hard to write
// so it should be hard to read
// I have to find a better job
last = first; /* Biblical reference */
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;
} catch (PartInitException pie) {
    // Mmm... pie
// This comment is self explanatory.
try {

catch (SQLException ex) {
    // Basically, without saying too much, you're screwed. Royally and totally.
catch(Exception ex)
    //If you thought you were screwed before, boy have I news for you!!!
virgin = 0;     /* you're not a virgin anymore, sweety */
public boolean isDirty() {
    //Why do you always go out and
    return dirty;
// TODO: Fix this.  Fix what?
Until (JesusChristsReturn) ' Not sure
if (/*you*/ $_GET['action']) { //celebrate
// I can't divide with zero, so I have to divide with something very similar
result = number / 0.00000000000001;
//Mr. Compiler, please do not read this.
catch (Ex as Exception)
     // oh crap, we should do something.
                -- Comment this later
/** Logger */
private Logger logger = Logger.getLogger();
$you = live("free") or die("hard");
if (case1) { // trivial
else { // we are screwed
 /* fill in later */

Monday, May 6, 2013