Saturday, February 11, 2012

Comments in source code

Honest comments:
// I'm sorry.
// Dear future me. Please forgive me.
// I can't even begin to express how sorry I am.
// I am not sure why this works but it fixes the problem.
// When I wrote this, only God and I understood that I was doing
// Now, God only knows
// If I from the future read this I'll back in time and kill myself.
// I am not sure if we need this, but too scared to delete.
// I am not responsible of this code.
// They made me write it, against my will.
// 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
Warnings:
/*
 * You may think you know what the following code does.
 * But you dont. Trust me
 * Fiddle with me, and youll spend many a sleppless
 * night cursing the moment you thought you be clever 
 * enough to "optimize" the code below.
 * Now close this file and go play with something else.
*/
// Magic. Do not touch.
// Dear maintainer:
// 
// Once you are done trying to 'optimize' this routine,
// and have realized what a terrible mistake that was,
// please increment the following counter as a warning
// to the next guy:
// 
// total_hours_wasted_here = 16
Sweet revenge:
// no comments for you
// it was hard to write
// so it should be hard to read
#define TRUE FALSE
// Happy debugging suckers
Exception up = new Exception("Something is really wrong.");
throw up; //ha ha
Plans for the future:
// drunk, fix later
// TODO: Remove this comment.
// TODO: The following if block should be reduced to one return statememt:
// return Regex.IsMatch(strTest, NAME_CHARS);
if (!Regex.IsMatch(strTest, NAME_CHARS))
   return false;
else
   return true;
// TODO: Fix this. Fix what?
Good names and values:
options.BatchSize = 300; // Madness? THIS IS SPARTA!
const int TEN = 10; // As if the value of 10 will fluctuate...
long john; // silver :D
double penetration; // ouch
And few comments by Captain Obvious:
// Increase i by one
i++;
return 1; // returns 1
/*
 * Method declaration
 * @param table
 * @param row
 * @throws SQLException
*/
void addTransactionDelete(Table table, Object row[]) throws SQLException {
/////////////////////////////////////// this is a well commented line
From closed question on stackoverflow

1 comment: