What are some general programming recommendations independant of Tcl

Purpose: Tcl is not just a language for the experienced programmer. This page is intended as a location where experienced programmers can provide general programming tips to those with less experience.

Learning from the mistakes of others is the sign of a lazy (or, in other words, productive <wink>) programmer...

The first items I have are a few truisms that I ran across that were written by Dan Sugalski on the perl 5 porters mailing list. They have nothing to do with perl in general and a LOT to do with good ideas for programmers!

  • Do The Right Thing, even if you don't want to.
  • Assume the person who'll need to maintain your code owns an axe and isn't afraid to use it
  • If you think something's terribly clever that's a good sign you shouldn't do it.
  • Don't take shortcuts to be cute or lazy.
  • Names are important! You're not called "x", so why should your variables
  • Pick a coding style and stick with it, even if you don't like it. If the program exists, use its style.
  • Things are only optional if it's painfully obvious what's going on without them. Parenthesis, generally speaking, aren't optional. Neither are meaningful comments.

Here are some more words of wisdom:

Alain Gravel

        When you find a bug be happy.  Squash it right away because it is likely to run away and make babies.
        ...This guy had lots of experience.  He didn't just produce code.
        He made real products work.  Worship its words...

Unknown source

        The intelligent man learns from its mistakes while the wise man learns from other's mistakes.
        ...Nothing to add to this...

        Divide and conquer.
        ...This is one of the most powerful debugging tool.  Test your modifications as often as possible
        on small pieces of the code.  If you can cut in half then cut agait until you isolate the problem...

Conclusion:

        Read the all the above once more and live by it!  M.T.

Another good resource are various books by Brian Kernighan, one of my favorite authors to read. For example, "The Elements of Programming Style". (Listed as out of print at amazon.com [L1 ].)


I recently gave one of our interns Kernighan and Plauger's "Software Tools" [L2 ] with the comment "This may be the best book ever on software engineering." -- CLN