I use a little tool that runs unit tests on compilation, when Im doing something new that unit tests works well with, I write a bunch of tests and just code until I have 100% tests passing.
If you make a lot of mistakes, have sanity tests cover your ass.
If you make a lot of mistakes, have sanity tests cover your ass.