Writing Solid Code
Writing Solid Code
Here is a checklist of stuff to keep in mind while writing software.
For every bug/defect reported:
- How could I have 'automatically' detected this bug?
- How could I have 'prevented' this bug?
- Enable all optional compiler warnings.
- Strengthen your prototypes ( const, unsigned, etc).
- Use LINT to catch bugs.
- If you have unit tests, run them.
- Use assertions to validate function arguments.
- Strip undefined behaviour from your code or use assertions to catch illegal uses of undefined behaviour.
- Comment unclear assertions.
- Assert or remove all assumptions.
- Use assertions to detect impossible conditions.
- Don't hide bugs when you program defensively.
- Use a second algorithm to validate your results.