automated vulnerability scanner

Secure coding

defensive programming

When rewriting code from grounds up, how do you know you will do better than the first write?