Subscribe to
NSLog(); Header Image

Deleting Code… Sometimes

Ned Batchelder has an interesting little ditty on deleting code in programming environments. His advice:

Select a section of code in your editor, hit the backspace key, and be done with it.

While this may seem like a great, simple way to handle things, in practice it isn't always the best. Ned says you can just use source control to find previous versions of code, but that's slower and far less convenient than having it "right there."

MailDrop has several blocks of commented out code. Some of them are delegate (usually delegate drawing) methods that - should we want to compile with them "on," we uncomment them. Some of them are previous versions of algorithms that we keep around in case a bug is introduced that a previous version did not have. Still other sections are maintained because they contained a bug, and it's important to make sure the new version(s) don't fall into the same traps. Finally, some sections are there because their replacement section is still a work in progress. And all of the developers know what sections are what, because we've left comments or emailed each other.

I'm a big fan of "never say never." Even Ned goes on to list several times when he has commented out old versions of code and left it. Is SCM great? Yeah. Is hunting for an old version of code in SCM faster than scrolling up a few lines? Hell no.