Scroll down
Don’t fix bugs later; fix them now.
Writing Solid Code: Microsoft's Techniques for Developing Bug-Free C Programs by Steve Maguire
ISBN: 1556155514 This book is available from Amazon
Never allow the same bug to bite you twice.
Don’t keep "trying" solutions until you find one that works. Take the time to find the correct solution.
Handle your special cases just one.
Don't clean up code unless the cleanup is critical to the product's success.
Enable all compiler warnings.
Chapter 1: A Hypothetical Compiler.
Use lint to catch bugs your compiler may miss.
Use a second algorithm to validate your results.
Chapter 2: Assert Yourself.
Step through every code path.
Chapter 4: Step Through Your Code.
Create thorough subsystem checks, and use them often.
Chapter 3: Fortify Your Subsystems.
Shred your garbage.
Document unclear assertions.
Don't hide bugs when you program defensively.
Either remove implicit assumptions, or assert that they are valid.
Maintain both ship and debug versions of your code.
Strip undefined behavior from your code.
Use assertions to detect impossible conditions.
Use assertions to validate all function arguments.
Design your tests carefully. Nothing should be arbitrary.
Chapter 3: Fortify Your Subsystem
Eliminate random behavior. Force bugs to be reproducible.
If something happens rarely, force it to happen often.
Strive to implement transparent integrity checks.
As you step through code, focus on data flow.
Don't wait until you have a bug to step through your code.
Always look for, and eliminate, flaws in your interfaces.
Chapter 5: Candy-Machine Interfaces.
Define explicit function arguments. Eliminate ambiguity.
Don't write multipurpose functions. Write separate functions to allow stronger argument validation.
Make code intelligible at the point of call. Avoid Boolean arguments.
Make it hard to ignore error conditions. Don't bury error codes in return values.
Write comments that emphasize potential hazards.
Write functions that, given valid inputs, cannot fail.
Always ask, "Can this variable or expression over- or underflow?"
Chapter 6: Risky Business.
Implement 'The Task' just once. Handle special cases just once.
Implement your designs as accurately as possible.
Don't reference memory that you don't own.
Chapter 7: Treacheries of the Trade.
Throw away your bag of tricks. Be truly clever: Write boring code.
Tight C code does not guarantee efficient machine code.
Don't allow unnecessary flexibility.
Chapter 8: The Rest Is Attitude.
Don't fix bugs later; fix them now.
Don't implement nonstrategic features. There is no free lunch.
Don't keep 'trying' solutions until you find one that works. Take the time to find the correct solution.
Fix the cause, not the symptom.
Write and test code in small chunks. Always test your code, even if that means your schedule will slip.