The adventures of Paul Robinson

There is a new round of discussion on the old comment your code or not chestnut:

Design for readability.

Even if you don’t intend anybody else to read your code, there’s still a very good chance that somebody will have to stare at your code and figure out what it does: That person is probably going to be you, twelve months from now.

Sure. Who wouldn’t agree with that?

But then the discussion goes a bit off the rails. I notice that Windows programmers love, love, love their IDE’s. I just don’t see how code completion can possibly be a significant productivity enhancer.

Programming is about thinking and communicating in code. It’s not about who can auto-complete obscure function calls the fastest.

Programmers ask me, “Shouldn’t I comment my code so that someone else can understand it?” My response to that is, “Why are you writing code that is hard to understand?”

I know that sounds jerk-off sarcastic, but really, I’m not trying to be. I’m seriously asking. Listen, writing good, clear comments takes time. It’s a non-trivial task. Given that, why not spend said time making the code clearer and more self-explanatory?

If a method does three different things with the middle thing being something obscure and hard to understand why not split that method into three methods each with a super clear and verbose name. Then when I read those methods called in sequence it will read like a story:

DoTheFirstThing();
NowDoThisTrickThingThatIsObscure();
NowDoSpecificallyThis();

Via Out of Cheese and Daring Fireball.

Comments

3 Responses to “Commented Code Doesn’t Equal Clear Code”

  1. Chris on April 10th, 2007 6:45 am

    In theory this sounds good, but in practice it’s a little more complicated. Even simple code can be hard to understand if you’re not familiar with the patterns being used. I find the level of documentation and required code clarity also depends on the context the code is being written. If I need to optimize an algorithm for performance, I’ll sometime sacrifice code clarity for a little extra speed, and carefully comment that code. Depending on the context, the trade-off is often worth it.

    With respect to the IDE thing, I used an IDE heavily when working in Java and it was wonderful. Not because it did auto-completion, but because I had the entire code base cross referenced directly in my editing environment. The code completion was just a minor improvement that I could easily do without.

  2. Software programmer on April 10th, 2007 9:09 am

    Yes correct, even clearly commented code could be hard to use sometimes. It takes a while to get used to the naming conventions and the little nitty gritties followed by the earlier software programmers. But It is always better to stick to the normal programming conventions though.

  3. Blog Reviews - Batch 1 » Dax Desai.com on April 11th, 2007 10:33 pm

    […] discussing technology primarily.  It is not the usual dry commentary.  He has articles such as Commented Code Doesn’t Equal Clear Code and “Thinking Messy Monitors”.  The latter reminded me of my own blog post - Increase […]

Leave a Reply




http://other.balamba.net/ http://for.balamba.net/ http://from.balamba.net/ http://frozen.balamba.net/ http://metro.balamba.net/ pale lesbian black black having man man sex led photo facial nude anime teen george michael fastlove mp3 jason anderson mp3 http://gigmp3.net http://blekly.net/ http://balamba.net/ some cut mp3
every mp3 time touch we adult mature video woman xxx real r kelly sex tape gay marriage laws in europe so what miles davis mp3 http://tomymp3.com/ http://glasshok.com/ xxx nineteen lesb my home Blog hot blog escort mature in london plavi orkestar odlazim mp3 bitch bury dig ditch artica myspace.com site sonata Arsis- We Are The Nightmare(video Version 1 And 2) face pic adult adult blooper videos porn for mp4 sexy guys with abs porn junky black celebrity man screensaver sexy
Close
E-mail It