The World According to Nick |
My take on Software, Technology, Politics, and anything else I feel like talking about. |
Tuesday, May 18, 2004
Programming in the GreenA while ago I linked to a post from Matt Warren called Programming in the Blue, which was a funny discussion on how keywords in a programming language should be determined by their text color, not the actual word. Anyway... I can't help but think of that post as I try to decipher someone else's code here at work. It's not because of too much color in the code mind you... it's because of too little color. What color do you mean? Green. Comments. Those little statements that explain what the point of a block of code is. When I write code... I add comments. Lots of comments. They help me when I go back and look at my code months later, and they help other people who have to read my code. Unfortunatly not everyone feels that way. One person in my group actually told me that he hates comments. In fact, when he goes though my code, he deletes all the comments and then reads it. Luckily he hasn't checked in any of that "modified" code yet, or I think I would scream. I estimate reading code with comments take 5 times less time to understand than un-commented code. Mostly because I'm more apt to choose to do something else over reading uncommented code. This whole discussion reminds me of something that happened to me while working at my last company. I was going through some C++/DCOM code that was obviously wizard generated. That means that it was full of variable names like t, and pT. Unfortunately, I needed to change that code by hand. So I went through and made modifications... but was running into some exceptions. Frustrated, I sent a copy of the file to my brother-in-law who is a software guru... and who I consider my mentor. When he called a couple days later... he complimented me on the code... and said that it was true guru code. What made it guru code you may ask? Well, he said, it has variables like pT and no comments. He of course then castized me for writing that code. I explained that *I* don't write code like that... it was wizard code that I modified. When *I* write code I use good names and add lots of comments. Ok, he asked... So why not change the variable names and add comments to the wizard code? Excellent question. From that day forth... I have tried not to let the fact that I didn't write the code affect my adding comments and good variable names. So go forth and write in green.
|
About Me
Name: Nick Home: Wauwatosa, WI, United States I'm a Software Consultant in the Milwaukee area. Among various geeky pursuits, I'm also an amateur triathlete, and enjoy rock climbing. I also like to think I'm a political pundit. View My Profile Archives
Home PagePrevious Posts
Destroying Elegant... no... Beautiful CodeDid You Know? Low Priority What a Way to Start a Morning Kerry MIA Again Blogger Update Being Unemployed in the Summer It Can't Make Toast... But It Can Order Pizza Hard to Manage a Server Programming with Perspective Personal Links
Carnival of the Badger
The Coding Monkey del.icio.us Links Flickr Photos Blog Critics Reviews Blogroll Me! music books video culture politics sports gaming www.flickr.com
This is a Flickr badge showing public photos from Nick_Schweitzer. Make your own badge here.
Credits
Design By maystar |