This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Funny Code comments

 
Saif Asif
Ranch Hand
Posts: 440
Eclipse IDE Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings fellow ranchers !

What is the best comment in source code you have ever encountered in your programming career ? Either written by your-self or by any fellow programmer . Do share here everyone !
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is even an article about a comment that burned into my brain: Who is Gregor Samsa?

I didn't really enjoy it when I first saw it, since I've discovered it a similar way. But, in retrospect, it is funny!
 
Saif Asif
Ranch Hand
Posts: 440
Eclipse IDE Hibernate Linux
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hehehe :-D good one ! I came accoss this once

 
Akhilesh Trivedi
Ranch Hand
Posts: 1603
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have heard people writing Bollywood songs in code comments that pass code-review stages and go in production.!
 
J. Kevin Robbins
Bartender
Pie
Posts: 1800
28
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a comment, but I once encountered a custom exception class called BlondeInputException.
 
Joe Ess
Bartender
Posts: 9300
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of my friends had an internship in West Virginia and he came back with a bunch of fun comments in the local dialect, for example, at the end of a series of conditions intended to whittle out non-compliant conditions:


Personally, I pepper my code with whatever I'm reading at the time, for example, I just saw a comment of a particularly relevant XKCD Comic
 
Saif Asif
Ranch Hand
Posts: 440
Eclipse IDE Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BlondeInputException.


:-D


Another one I remember was something like this

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64978
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Way back in the Ice Ages when I was writing applications for Windows, I remember there was one section of code in an app that was the epitome of unreadable, unmaintainable, unintelligible code. It had been written by a long-since-departed contractor and was a crucial piece of the system that just about everything needed to use. It was riddled with bugs, but all the other code did ridiculous and over-complicated gyrations to get around the bugs, rather than anyone braving trying to fix the noxious code.

The comment on that block (I've saved it -- the comment, not the code -- to this day):

 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:

Which reminds me of this Dilpert Strip:

http://dilbert.com/strips/comic/2013-02-24/
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I once saw, in production, live, out-in-the-world code:

x = 5; // set x to 5
 
Saif Asif
Ranch Hand
Posts: 440
Eclipse IDE Hibernate Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it reminds me of another "mocking" comment I found in a C/C++ application back when I was a C developer

 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saif Asif wrote:it reminds me of another "mocking" comment I found in a C/C++ application back when I was a C developer



Source: http://stackoverflow.com/questions/184618/what-is-the-best-comment-in-source-code-you-have-ever-encountered
 
Saif Asif
Ranch Hand
Posts: 440
Eclipse IDE Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow ! Now I know from where it ended up in our app !
 
Saif Asif
Ranch Hand
Posts: 440
Eclipse IDE Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another one
 
Saif Asif
Ranch Hand
Posts: 440
Eclipse IDE Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quite recently I came across this .

 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saif Asif wrote:Wow ! Now I know from where it ended up in our app !

Along with all the other ones you have quoted in this thread.
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Recently saw this....
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Not in a comment, but I once ran across production code that essentially depended on that to work correctly. We received messages from a stock exchange with 1=buy and 2=sell, or something like that. The libraries we used transformed those into their own values--103 and 101 I believe.

Then one day I had to test a subset of the system in isolation. Where it had been exchange --> lib1 --> lib2 --> app, I changed it to simulator --> lib2 --> app. Everything broke. Horribly. After some digging I found out that all the simulated buys were being treated by the app as sells and vice versa. At first I freaked out, thinking we had a huge CF in production. After a moment I calmed down and realized that if that had been the case, there would have been screaming up and down the halls long ago.

After some digging, I found something like this:



So lib1 turned a buy into a sell, and lib2 turned it back into a buy, so that our app saw the semantics the exchange sent out, albeit via the scenic route. Two wrongs made a right and all was well, as long as we didn't try to separate lib1 from lib2, where the permanent crossing of the streams was the only thing that kept things working.
 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff's comment reminds me of a more horrible version:

Some more I've seen:




 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anayonkar Shivalkar wrote:

Someone apparently reads XKCD.
 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martin Vajsar wrote:Someone apparently reads XKCD.

Wow... I read that code on some forum (I guess StackOverFlow)
 
Lalit Mehra
Ranch Hand
Posts: 384
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once I was working on someone's else code ... had to fix it actually ... but as the time slot was really really short ... i just bunked it and put a comment

Something weird is happening here ... I don't what ...
 
Saif Asif
Ranch Hand
Posts: 440
Eclipse IDE Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I remember writing this numerous times in my code. Even still I write it.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic