|
-
Sep 10th, 2001, 09:51 PM
#6
More than just that -
1. Use self-Documenting variable & function names, except for loop counters. --- char *buf, int i, and all that should be only for working variables.
2. Avoid trying to write elegant code, the compiler is smart enough to make good, tight machine language.
Elegant equals: terse, hard to read, many functions crammed into one statement.
3. Keep functions to the point. Don't try to have one function do 8 things. Any function longer than one page (about 50-80 lines)
becomes hard to read six months later. Dissect a function down to it's elements - for example - Trim is the same as calling Ltrim then Rtrim. Don't write a separate Trim function, use existing code. Reduces probability of bugs a lot. The only time this isn't true is writing gaming software where in-lining is a standard method to increase both speed and bugs.
4. Put all of your #define, #include and other directive statements at the very top of the file. Don't sprinkle them around.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|