Krishna Kumar is a software development manager from New Hampshire. He writes on topics related to software development, programming, project management, and business management. Krishna is a DZone MVB and is not an employee of DZone and has posted 41 posts at DZone. You can read more from them at their website. View Full User Profile

Commented Out Code

04.24.2011
| 4440 views |
  • submit to reddit

This post at Visual Studio Magazine by Peter Vogel has invited a lot of contempt (via Rob Conery):

I never delete code — you never know when you might want it back. So I spend a lot of time commenting out code. I do this so often, and mousing up to the menu takes so long, that I’ve memorized the keystroke combination for commenting/uncommenting code. It’s actually one of the few keystroke combinations — other than Undo — that I remember.

Many people assumed that Peter did not use (or know) how to use source control, but as Peter’s replies in the comments section show, he does use version control, but apparently seems to have an aversion to using Diff, possibly because he hasn’t grown comfortable enough exploring how to use source control properly.

I find the lack of knowledge of proper source control to be one of the most common gaps in developers. Even excellent programmers with good command of technology seem to fail when it comes to source control features beyond the basics. I am not sure why this is. Perhaps it is because they think of it as a backup solution (to protect against some hard disk disaster) than something that actively helps them in their development.

To somewhat complicate the issue, there are quite a few different flavors of source control systems out there. There was the horrendous Visual SourceSafe with its file-based system. You have centralized source control systems. I am particularly fond of Sourcegear Vault, a rather inexpensive and competent solution compared to others. And now you have distributed systems such as Git and Mercurial. All of these systems have some similar concepts, but some dramatically different ideas and then their implementations of common concepts can also vary. I have seen some articles from experienced developers trying to relate their prior experience with Subversion to Git and ending up frustrated.

The other practical roadblock to learning source control systems is that the manual approach can sometimes seem easier if you don’t know how things like branching and merging work. Take a backup, use brute force, and so on. Also there is usually one single source control administrator (with centralized source control) who decides how people should use the repository and so everyone in the team learns it that way.

To be optimistic for a minute, the increase in online source control systems like Github, Kiln, Bitbucket and others is putting a dent in this knowledge gap. If you are a programmer who enjoys tinkering at home, there is no excuse to not use one of these tools, especially the ones that offer free private repositories. Even the paid accounts are not costly either. It would be good to work with some friends on a joint project. And bonus – you can now upload your projects to some of these repositories which then automatically deploy them to sites such as AppHarbor and Heroku. I recently did something with AppHarbor and Bitbucket and yes, it is indistinguishable from magic.

 

From http://www.thoughtclusters.com/2011/04/commented-out-code/

Published at DZone with permission of Krishna Kumar, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Liran Mendelovich replied on Mon, 2011/04/25 - 2:23pm

I have an issue to talk about, with all relevant people, not necessarily just the author:
And bonus – you can now upload your projects to some of these repositories which then automatically deploy them to sites such as AppHarbor and Heroku

I am curious - how good are these services in comparison to Amazon EC2 ? I saw that Heroku has layers that acts like: you have some number of machines ('dynos' like CPU's) dedicated to your project, and a layer which act like a load balancer, that redirect HTTP requests to the available machines. At Amazon EC2, it has these layers too ? Ii has several machines for your project, but it has some layer of load balancing like I described too ?
I read a little about comparisons between.
What do you people with knowledge can share about these issues ? Scalability of these services, reliability, and more ? Thanks * And about the main issue of this post - yes, version control system is great.

Philippe Lhoste replied on Tue, 2011/04/26 - 7:52am

I worked for a company, doing one of the first Web-based e-mail systems in C-based CGI.
At the time, we used Visual Enabler as VCS, but I think we introduced it late, so we developed a curious practice:
To be able to revert to a previous state, we kept all the old code, which we commented it out with C's pre-processor:

#ifdef OLD // Change of 1999-04-26
// This is old code
#else
// The new bug free code...
#endif

As you can guess, the sources were awful, nearly unreadable.
After a while, we started to clean up the oldest parts, I developed a Visual Studio macro to jump to the next # part and another to remove the "old" part, taking in account nested sections...
Indeed, VCS and diff should do a better job for this, and if one want to keep a useful code snippet no longer useful in its context, one can make a code bank, repository of snippets...

Shoaib Almas replied on Sat, 2012/08/25 - 5:47am

Maybe once in a while screenshots would be good for this kind of article, just a thought. I have no idea what it is about, Google is my best friend right? Also I am not getting your posts in the email, I resubscribed but wonder if you may want to check that for a bug on your next post. You writing a good blog I say, glad I bookmarked it (from the software dev. is hard post months ago)

Thanks, grateful self learner (only if I quit do I mess it up or fail, too much time in this to stop or give up.) Screen shots could work nice for something you do, just an idea

Java Forum

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.