What is your favorite comment you came across in code?

30    25 Jun 2015 01:52 by u/for_satan

Whether your own comments or code you ran across in the wild.

24 comments

16

Back in the day, in an age before the internet here was a COBOL payroll system. The system ran weekly. There was an error message generated for the check stub description line if an amount had more than 4 digits for dollars (>9999.00). The error message was "THIS PERSON MAKES TOO MUCH MONEY". It was triggered. Management was...somewhat less than pleased.

10

float Q_rsqrt( float number )
{
    long i;
    float x2, y;
    const float threehalfs = 1.5F;
    x2 = number * 0.5F;
    y  = number;
    i  = * ( long * ) &y;                       // evil floating point bit level hacking
    i  = 0x5f3759df - ( i >> 1 );               // what the fuck?   <-- THIS HERE
    y  = * ( float * ) &i;
    y  = y * ( threehalfs - ( x2 * y * y ) );   // 1st iteration
//  y  = y * ( threehalfs - ( x2 * y * y ) );   // 2nd iteration, this can be removed
    return y;
}

Probably a few others in business apps, but they elicit the wtf, and don't ask it.

4

That one is always a good one. Made a lot of game code faster.

10

I have two that come to mind:

First one was a piece of software used to simulate some military hardware interface. Since I do not have access to the code anymore, this is a recreation from memory:

// The following code is sub-par. We know. There have been several
// attempts to improve the code, but all attempts have failed. To warn
// future brave souls, increase the counter when you admit defeat.
//
// Defeated souls count: 17
...

And another one, which I merely have observed on the Internet (Edit: As pointed out by Enemby; this one is from xkcd):

int random() {
    return 4; // chosen by fair dice roll; guaranteed to be random
}
2

the 2nd one is from xkcd.

0

How could I not remember that?!

9

I can't remember it exactly, but it was something like:

Don't edit this function. It looks screwy, you know It, I know It.
But it works. Seriously, don't change it. $TeamLead, I'm talking to you.

Backstory: My team lead was heavily against using any 3rd party code, including frameworks (writing PHP like it was 1998, but it was just two years ago!).

So I had to writing something that does pretty much what Carbon does, but object oriented code wasn't used on this project. Had to do it as procedural with several functions. Any attempt to just scrap the file and rewrite it would end up just as corrupted with spaghetti as before as he made some edits. I'd get it working, he'd break it again. I lasted 6 months at that job.

1

We had something similar in a code base that I worked in, effectively

This is 10, because this is what the app needs

It was also PHP coded like 99, in 2012

1

Same kind of mentality I had to face. It was salt in the wound because I took the job out of necessity. I had to drive over 40 miles one way, so it took me nearly an hour because of traffic when driving.

4

If a company survives long enough on products like that, they usually start asking why development is so expensive, then they outsource to Indians which sends the company into a swan dive above concrete.

2

Oh they already did that for the HTML/CSS. Tables. Tables everywhere. Nested. I was surprised it didn't say "best viewed in IE".

7

Came across a set of comments in an automated mrp export program written in c that is about 10 years old

//if (qty == 507)

//return;

//why the fuck did I have to comment this out

//why did you even setup this fuck you bomb to go off 3 years after you left

Or something like that haha, I of course left it in

6
if ($response->error) { // sometimes our response times out
// do something
} else { // but the dude abides
// do something else
}
3

I like this one:

// sometimes I believe the compiler ignores all my comments

And this one;

#define TRUE 0 // Happy debugging suckers!
#define FALSE 1
2

Not really a comment, but when I was modding a game, the original maker called the variables for time and date $whatTimeIsItScoob and $likeNowScoob.

2

#define POPE_IS_CATHOLIC 1

if (POPE_IS_CATHOLIC){ code }

1

There is a music lyric website aggregator software called LyricJam. It scrapes lyric content from a variety of sites. The scraper base class is called ScrapeJam. Here's the comment for the class:

https://github.com/ss23/Lyrics-Database/blob/dev/Scrapers/ScrapeJam.py#L47

1

TODO:

It always cracks me up.

0

/**

*MAGIC STARTS HERE, DO NOT TOUCH

*

*/