Good Code is...

 

 
bullet

...Fast. 

bullet

...No faster than it needs to be.  Don't waste time ratcheting functions so tight that they bleed.  

bullet

...Random.  If there's visual repetition as you read through your code, you probably need more subroutines.

bullet

...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.

bullet

...Not excessively general.  If you're not working on an operating system or a utility module, then don't write one.

bullet

...Accented with tasteful comments, including a few that are paragraphs in length and address the big picture. 

bullet

...Is easy to read even with minimal comments.

bullet

...Is developed with a version control system.  Except in the earliest stages, diff every file when you check it in.

bullet

...Is tested and debugged with the most advanced automation available.  Hey, if you can find bugs automatically, that's just plain smart.

bullet

...Is written on the fastest computer you can buy; that way, you don't have to change machines as often.

bullet

...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.

bullet

...Always keeps working, more or less, throughout the development process.  Once you've got something working, keep it working.

bullet

...Has well-named functions, variables, and modules.  Often, a good name for a loop variable is i.

bullet

...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.

bullet

...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.

bullet

...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.

bullet

...Uses frameworks and libraries wherever possible.  Don't reinvent the wheel.

bullet

...Doesn't return errors for "can't happen" conditions, a.k.a. asserts.

bullet

...Uses plenty of ASSERTs to discover bad state as soon as possible.

 

Back Home Up

www.CharlieAnderson.com    Since 1998, Your Home for Charlie Anderson Information    Send me email: info@charlieanderson.com 


All Content 1998-2002 Charles R. Anderson    This page was last modified on 11/13/2003