View Full Version : How do you write maintainable code?

10-12-2005, 08:15 PM
I have developed a few tips, but would like to hear your ideas too.

Never nest parentheses. I refactor any simple inner expression as its own local variable.
Type both opening/closing brackets/parentheses/quotes before entering any content. I type both the opening and closing, then left arrow, and enter the inner content (then right arrow, if needed). If I abandon this construct to refactor out some complicating subexpression, then at least this expression will be syntactically complete on its own.

I have many others, but would like to hear others tips as well.

10-12-2005, 09:37 PM
comments are your friends
there is no substitute for good naming conventions
each function does ONE thing (procedural coding basic for good code) and it is encapsulated in "black box" fashion
avoid global variables when at all possible. If it isn't a pseudo-constant, you probably don't need it to be global.