 |
...Fast. |
 |
...No faster than it needs to be. Don't
waste time ratcheting functions so tight that they bleed. |
 |
...Random. If there's visual repetition
as you read through your code, you probably need more subroutines. |
 |
...Clean. Don't comment out every third
line and leave it that way forever. If you want to turn on some old
code, that's what version control systems are for. |
 |
...Not excessively general. If you're
not working on an operating system or a utility module, then don't write
one. |
 |
...Accented with tasteful comments, including
a few that are paragraphs in length and address the big picture.
|
 |
...Is easy to read even with minimal
comments. |
 |
...Is developed with a version
control system. Except in the earliest stages, diff every file when you check it in. |
 |
...Is tested and debugged with the most advanced
automation available. Hey, if you can find bugs automatically,
that's just plain smart. |
 |
...Is written on the fastest computer you can
buy; that way, you don't have to change machines as often. |
 |
...Malleable. There's almost always time to
make the code better. It isn't dangerous to rename some badly named
variables and functions, and someday, you'll
thank yourself. |
 |
...Always keeps working, more or less,
throughout the development process. Once you've got something
working, keep it working. |
 |
...Has well-named functions, variables, and modules. Often, a good name for a loop
variable is i. |
 |
...Has consistent naming and formatting
conventions. Pick a set and stay with them. Nothing is less
productive
than changing code to keep up with this week's style convention. |
 |
...Simple. Keep functions short and
obvious. If they're longer than 20 lines, consider some helper
functions. 200 line functions are never
necessary. Have you put a stopwatch recently on the overhead of a
function call? It ain't much. |
 |
...Is likely to use objects, but not overuse
them. Use objects for the key elements in your program. Don't
wrap every damn thing in object clothes. |
 |
...Uses frameworks and libraries
wherever possible. Don't reinvent the wheel. |
 |
...Doesn't return errors for "can't happen"
conditions, a.k.a. asserts. |
 |
...Uses plenty of ASSERTs to discover bad
state as soon as possible. |