These are the rules from The Elements of Programming Style by Brian W. Kernighan and P. J. Plauger. They haven’t steered me wrong yet and most remain as relevant today as they were when they were first published.
10.0 times 0.1 is hardly ever 1.0. Avoid ELSE GOTO and ELSE RETURN.archaic Avoid multiple exits from loops. Avoid temporary variables. Avoid the Fortran arithmetic IF.archaic Avoid THEN-IF and null ELSE. Avoid unnecessary branches. Choose a data representation that makes the program simple. Choose variable names that won't be confused. Document your data layouts. Don't comment bad code – rewrite it. Don't compare floating point numbers solely for equality. Don't diddle code to make it faster – find a better algorithm. Don't just echo the code with comments – make every comment count. Don't over-comment. Don't patch bad code – rewrite it. Don't sacrifice clarity for small gains in efficiency. Don't stop at one bug. Don't stop with your first draft. Don't strain to re-use code; reorganize instead. Don't use conditional branches as a substitute for a logical expression. Each module should do one thing well. Follow each decision as closely as possible with its associated action. Format a program to help the reader understand it. Identify bad input; recover if possible. Indent to show the logical structure of a program. Initialize constants with DATA statements or INITIAL attributes; initialize variables with executable code.archaic Instrument your programs. Measure before making efficiency changes. Keep it right when you make it faster. Keep it simple to make it faster. Let the data structure the program. Let the machine do the dirty work. Let your compiler do the simple optimizations. Localize input and output in subroutines. Make input easy to prepare and output self-explanatory. Make input easy to proofread. Make it clear before you make it faster. Make it right before you make it faster. Make sure all variables are initialized before use. Make sure comments and code agree. Make sure every module hides something. Make sure input cannot violate the limits of the program. Make sure special cases are truly special. Make sure your code does nothing gracefully. Make the coupling between modules visible. Make your programs read from top to bottom. Modularize. Use procedures and functions. Parenthesize to avoid ambiguity. Program defensively Replace repetitive expressions by calls to common functions. Say what you mean, simply and directly Take care to branch the right way on equality. Terminate input by end-of-file marker, not by count. Test input for validity and plausibility. Test programs at their boundary values. Treat end of file conditions in a uniform manner. Use data arrays to avoid repetitive control sequences. Use debugging compilers. Use DO and DO-WHILE to emphasize the presence of loops. Use DO-END and indenting to delimit groups of statements. Use free-form input when possible. Use IF ... ELSE IF ... ELSE IF ... ELSE ... to implement multi-way branches. Use IF-ELSE to emphasize that only one of two actions is to be performed. Use library functions. Use recursive procedures for recursively-defined data structures. Use self-identifying input. Allow defaults. Echo both on output. Use statement labels that mean something. Use the fundamental control flow constructs. Use the good features of a language; avoid the bad ones. Use the telephone test for readability. Use uniform input formats. Use variable names that mean something. Watch out for off-by-one errors. Write and test a big program in small pieces. Write clearly – don't be too clever Write clearly – don't sacrifice clarity for efficiency. Write first in an easy-to-understand pseudo-language; then translate into whatever language you have to use.