Avoiding bugs is better than fixing them.
- Use contracts.
- Use unit tests.
- Use code reviews.
- Favor bug fixes over new features.
- Favor static typing which provides more error checking at compile-time.
- Heed compile-time warnings.
See also: DetectingBugsEarlier, DebuggingTopics