What is the best comment in source code you have ever encountered?
rescue
# silently, we fail
# many validations fade
# like tear drops in rain
end
This is just one of many...
-
1
Found this in makefile
# ===== Never edit below this line. Ever. Or I'll kick your ass. ====
'Mind boggling, gibberish version of a SQL statement, but it work's, so dont touch it
-
4
My favorite comment of all time was used by a gay friend of mine. He liked to mark all of his TODO comments in VB.NET as
'TODO: Matt Damon
Sometimes additional information was provided but not usually.
This was actually made by me when I was implementing a prototype turned into real code:
// Abandon all hope you who needs to debug this
Yes, someone smarter than me actually refactored the code afterwards (it had to have a good ending).
"This will never happen".
Famous last words my friend...
-
1
-
Linux Comments
There are heaps of good ones here ...
These are all comments in linux
http://lwn.net/1998/1015/a/f-word.html
My Favourites:
./arch/sparc/kernel/ptrace.c
/* Fuck me gently with a chainsaw... */
./drivers/scsi/qlogicpti.h
/* Am I fucking pedantic or what? */
Not code comments, but SVN commit comments on the same file:
First commit (following of dozens of others after results coming back from testers):
Squashed some IPR mod bugs. The were big and juicy ones, too.
2nd commit:
Squashed some more mod bugs. Those are some nasty bugs, them mod bugs...
3rd:
Squashed some more mod bugs. They are like cockroaches: they'll live through a nuclear war.
4th:
Squashed some more John bugs. They too are like cockroaches: they appear anywhere John goes. Wait. That doesn't sound right.
And 5th:
Same John bug. It didn't die, just played 'possum.
Yes, I was tired of "Fixed bug".
I like some of the comments in the GNU binutils. This one is from BFD som.c:
/* You'll never believe all this is necessary to handle relocations
for function calls. Having to compute and pack the argument
relocation bits is the real nightmare.
If you're interested in how this works, just forget it. You really
do not want to know about this braindamage. */
This one too:
/* Don't ask about these magic sequences. I took them straight
from gas-1.36 which took them from the a.out man page. */
...
/* Keep track of exactly where we are within a particular
space. This is necessary as the braindamaged HPUX
loader will create holes between subspaces *and*
subspace alignments are *NOT* preserved. What a crock. */
Another one:
/* We will NOT put a fucking timestamp in the header here. Every
time you put it back, I will come in and take it out again. ... */
From gas:
/* Yes this is ugly (storing the broken_word pointer
in the symbol slot). Still, this whole chunk of
code is ugly, and I don't feel like doing anything
about it. Think of it as stubbornness in action. */
I guess it got viral, I found the following in a daemon (Linux) that prevents the OOM killer from selecting it:
/*
* Don't OOM me, bro!
*/
This was right after a mlockall() to prevent the process from swapping, commented:
/*
* Don't swap me, bro!
*/
-
1
/* FIXME This must absolutely be removed before 4.0.7 release
* TODO really remove this */
we have since released a 4.0.7, 4.0.8, 4.0.9 and 4.1 version...
I once worked on a project where I found this comment:
// Cabbage fart?
I have no idea what it was supposed to mean. Just glad my cube wasn't next to whoever wrote it.
-
1
v.bpc := v.pc; -- Remember to jump back
v.baccu := accu; -- Yo dawg, heard you like runing instructions
-- so I took backup of your accu so you can run
-- instructions while you run instructions.
v.flags.i := false; -- No more interupts
Well, here's one I just committed:
/* Every time I re-visit this function, I feel like
* I need to take a shower.
*
* Don't get too used to this function, its days are
* numbered.
*/
Someone could start something like greatcodecomments.com and make some cash. That person, however, is not me.
My favorite (which I must admit I've used many times):
// Yes...I know this is repulsive and stupid.
// But <%CompanyOwnerOrManagerToken%>, not knowing a thing about code,
// demanded I do it anyways. SO, go crap on their desk, not mine.
// K THX BYE
/* Here I sit, Joe broken hearted, came to do some sh*t, but only just started. */
In regards to some heavy regular expression input validation.
In the middle of a few thousand line JScript file after a completely arbitrary line...
// The world is a happy place.
In the header of an XSLT file:
DON'T TOUCH THIS SCRIPT -> XSLT is like arcane, black magic
int Q13Factor = 8125; // 2^13 for Q13
-
I'm guessing it started at 8192 (2^13), then dodgy bug-squashing techniques brought it down to 8125, and the comment stayed on, now untrue. – jpinto3912 Oct 13 '08 at 15:00
Found in the JUnit API:
/**
* ...as the moon sets over the early morning Merlin, Oregon
* mountains, our intrepid adventurers type...
*/
public Test createTest(Class theClass, String name) {
...
}
// TODO - Comment this function
-
6
-
1
I don't remember exactly, but the idea was something like this:
Person p = new Person("John", "Doe", "male");
Collection women = new ArrayList();
women.insert(p.getTail());
It's dirty code ;)
-
24
-
1
-
5As dirty as that code reads, the result is that you put a male in a collection of women. So when the next programmer uses the list of women, he gets a male and uses it as a woman. So whereas the first programmer thinks his guy is lucky, the next one ensures the guy gets the equivalent treatment of dropping the soap. – Lee Louviere Jan 27 '11 at 21:00
// Whoever put this here is an idiot...this doesn't work at all !
But the code is still there...
Seen in the source code for LucasArts' computer game 'The Eidolon' (Which was wierd and wacky in it's own right)...
// He's dead, Jim!
From a lad that clearly had been watching Monty Python:
> // And now, for something completely > // different:
class theLarch{
// fix for groupid > 9
// if groupid ever gets to 100 everything will break (again)
if (groupid < 10) {
groupid = "0" + groupid;
}
-
Very nice. It probably took longer to write that comment than to fix the damn thing! – Martin Cote Apr 26 '09 at 21:19