I do the same as Charles Kens said: Test-first programming, test-driven development.

Defects have been rare. Most bugs have been fixed immediately (as in: report received, pass to developer, write test, fix bug) and I recall only a handful that were larger and we chose to schedule them as separate tasks.