Slashdot Mirror


How to Keep Your Code From Destroying You

An anonymous reader writes "IBM DeveloperWorks has a few quick tips on how to write maintainable code that won't leech your most valuable resource — time. These six tips on how to write maintainable code are guaranteed to save you time and frustration: one minute spent writing comments can save you an hour of anguish. Bad code gets written all the time. But it doesn't have to be that way. Its time to ask yourself if its time for you to convert to the clean code religion."

7 of 486 comments (clear)

  1. Summary: Beginners need tips too. by Palmyst · · Score: 5, Informative

    The article is suited for beginning programmers, I guess. Here is the summary of the tips.

    1. Comment smartly.
    2. Name your constants ("use #defines").
    3. Descriptive variable names, but not too long.
    4. Handle errors.
    5. Avoid premature optimization.
    6. Clarity is better than cleverness.

    The author may not be a beginning programmer, but it appears that he might be a beginning writer on programming.

  2. Re:The whole article is -1 redundant. by Anonymous Coward · · Score: 3, Informative

    I am trying to maintain code written by a senior designer (logic code). This developer did not believe these rules. It is hell. This is not redundant.

  3. Re:Who wrote that article? by KingSkippus · · Score: 5, Informative

    Maybe it was the note at the top of the article that says, "Level: Introductory."

    Maybe it was the author's comment at the end that said, "At this point, you may be thinking, 'Wow. That was a big waste of time. All of this stuff is obvious and everyone knows it. Why did anyone write all of this?' I hope this is what you're thinking. Then you're already smart. Good for you."

    But somewhere along the course of reading the article, I got the impression that he wasn't writing it for professional developers (at least, smart ones), but for people relatively new to programming.

    But then, maybe I'm just stating the obvious, Cap'n...

  4. Re:Who wrote that article? by jjrockman · · Score: 3, Informative

    Not to nitpick, but it's not "by Microsoft". It's published by Microsoft, but written by Steve McConnell of Construx.

    --
    Quit jabbering on the phone while driving. You are not that important.
  5. A Note From the Author by spidweb · · Score: 5, Informative

    As the person who actually wrote the article in question, I'd like to thank you for your comments and respond with a few of my own.

    * To those who think it is all so obvious that I shouldn't have written about it:

    No. You are wrong. Just wrong. Good programming practices do not just appear in peoples' heads as if by magic.

    It's an introductory article. It's sold as an introductory article. And I am far more interested in being Right than I am scared of being Obvious.

    * To those who have problems with suggesting using #define instead of const int

    Meh. Yeah, you're probably right. But the important thing here is the CONCEPT of having your constants being defined in one central, easy to find place. Once a person has that down, he or she can define them however is desired.

    * To those who accuse me of being a (gasp) inexperienced programming writer.

    Yeah. So what? I never said I wasn't. I'm a game author. I've written over a dozen games. They all made money. That doesn't mean I am mister programming advice god.

    But one, if you have a problem with it, yell at IBM, not me. They're the ones who had me write the piece.

    Two. This is kind of ad hominem. Who cares how experienced I am or am not? I'm still right.

    * I didn't read the article, but I'll say bad things about you because it means I'm awesome.

    R0ck 0n d00d. First post!

    * I liked the article. It might tell beginning programmers something actually useful.

    If anyone says this, thanks in advance.

    --
    - Jeff Vogel
    Spiderweb Software
    Fantasy RPGs for Mac and Windows.
    http://www.spiderwebsoftware.com
  6. Re:Who wrote that article? by spidweb · · Score: 5, Informative

    A brief defense from the person who wrote the article.

    The indenting in the selected code was not mine. It got screwed up somewhere between my machine and being posted on their site. I'll drop them a not and ask them to fix it.

    No, I am not insane. :-)

    --
    - Jeff Vogel
    Spiderweb Software
    Fantasy RPGs for Mac and Windows.
    http://www.spiderwebsoftware.com
  7. Re:Who wrote that article? by Anonymous+Brave+Guy · · Score: 3, Informative

    Very little apart from failing to respect scope and not encoding any type information?

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.