Most coders would have seen the excellent thread on StackOverflow about the best comments they have seen in code base. Even if you are not a coder, I suggest you do check out the posts there to convince yourself that coders are not really boring; this myth has been spread for too long. People have different theories about adding comments in code. Some hardliners believe that if you have to add comments to code, you are doing it wrong. There are the others who believe code needs to be well commented. I belong to the latter, but again my commenting style defies my own common sense. When I write not so good code, I try to go under the radar and leave it sparsely commented like I was nowhere there, and when I write code I’m happy about I wax eloquent.
In addition to comments that explain code you would find some wonderfully funny comments in code, some intentional and some unintentional. You would have seen some such hilarious comments in Open Source Code. It would be nice if we could get a glimpse into some of the comments in proprietary software too without revealing too much into code. The previous company I worked for had a humongous codebase interspersed with pretty good humorous comments. I remember one such occasion when I was debugging a bootup issue and I figured out which part of the code was problematic, but had a tough time understanding what it does. Bang at the top of this file was something like – “Sorry dude. I’m not adding any comments here. I took a whole day figuring out what this piece does. I’m not telling it for free”. I still hate that guy. Here are some of the good ones I remember from the Exotel code base.
The CEO Shivku adds extremely useful comments to explain pieces of code he has written. Bringing the ode to code
Nijanthan saves the planet by adding comments to a block of code which would never have been understood otherwise
CTO decides to pass some random commentary on languages for being lazy. Basically I’m CTO, I can be lazy, minions adhere to coding guidelines. Also I’m a Microsoft fanboy.
Yours truly decides to get to get all philosophical. Such exaggerated drama just to say that the function returns back a huge blob of data it got from another function.
Since we name projects after Asterix characters, Ishwar decides that mentioning relationships between characters will help people understand what code does.
Kailash goes ballistic over some piece of code or he is having a NSFW conversation with the code he is writing
The CEO at it again. Code added in January 2013. Today never came.
Yeah. Ever seen that? Diverting a reader from ugly code with performance gains. Ishwar does it like a boss.
Yours truly tries a juvenlie Indian version of “No donuts for you”. Kadala Mittai is Tamil for Peanut Candy
The CTO gets all excited about some triple hacky code he is going to write
Govind uses local slang from Chennai to explain a race condition
Karthik announces the start of impending danger emphatically, but forgets to end it
I’m sure your codebase has much more hilarious comments. Do share it and when you do tag it with #OdeToCode.