{ by david linsin }

June 04, 2007

Comprehensible Code

The developerworks article Six ways to write more comprehensible code explains 6 obvious things you should consider when writing your code:

Tip 1: Comment like a smart person.
Tip 2: Use #define a lot. No, a LOT.
Tip 3: Don't use variable names that will mock you.
Tip 4: Do error checking. You make errors. Yes, you.
Tip 5: "Premature optimization is the root of all evil." - Donald Knuth
Tip 6: Don't be too clever by half.

Tip 2 in Java terms would be global variables or static variables. Most of the time defined in a common interface, so that they are accessible from all of your code. I agree with the tip. I just think you shouldn't go over board. If you go too far and define too many, you'll end up defining more and more, which will lead to a big mess in respect of maintainability.

I really like the conclusion:

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 don't think that all of this is obvious to everyone. It's really not. Bad code gets written all the time. But it doesn't have to be that way.
...

0 comments:


com_channels

  • mail(dlinsin@gmail.com)
  • jabber(dlinsin@gmail.com)
  • skype(dlinsin)

recent_postings

loading...