Blog

Commented-Out Code and Broken Windows

September 21, 2008

I know that there are numerous blog posts already written about this topic, but I just can't resist. I've just had it with commented-out code. Sure, everybody agrees that this is evil in it's purest form, but why do I still have to endure so much commented-out code. It's bad for my heart.

Don't trust the source-control system? Get rid of it and replace is with a more reliable source-control system then. Check in more often! Feeling guilty about throwing away code? Too bad, go see a shrink or something. Keep your code clean at all times!

To me, a piece of code that contains commented-out lines is just another piece of crap. Most developers tend to just remove the commented-out lines and get on with it. I'm a bit more radical about this. I tend to throw away the whole shebang, like a tumor that needs to be removed along with it's roots. That's right. I remove all of the surrounding code as well.

Writing software is an act of discipline. Commented-out code is like a broken window. It introduces rot into a software system.

What triggered me to write this blog post besides the fact that I just can't stand commented-out code and have to see so much of it? Well, I was reading the foreword of the book Clean Code which mentioned this again (and also chapter 4). Why does this need to be written down again and again (including this blog post, I know, I know)? It's like periodically publishing articles in the newspapers that leaving dead bodies laying around is on the street is a bad thing. Isn't this just common sense? Not in this industry.

Glad that I've got this from my chest. Again.

Jan, the relieved

If you and your team want to learn more about how to write maintainable unit tests and get the most out of TDD practices, make sure to have look at our trainings and workshops or check out the books section. Feel free to reach out at infonull@nullprincipal-itnull.be.

Profile picture of Jan Van Ryswyck

Jan Van Ryswyck

Thank you for visiting my blog. I’m a professional software developer since Y2K. A blogger since Y2K+5. Provider of training and coaching in XP practices. Curator of the Awesome Talks list. Past organizer of the European Virtual ALT.NET meetings. Thinking and learning about all kinds of technologies since forever.

Comments

About

Thank you for visiting my website. I’m a professional software developer since Y2K. A blogger since Y2K+5. Author of Writing Maintainable Unit Tests. Provider of training and coaching in XP practices. Curator of the Awesome Talks list. Thinking and learning about all kinds of technologies since forever.

Contact information

(+32) 496 38 00 82

infonull@nullprincipal-itnull.be