XP (eXtreme Programming) advocates Test Driven Development, where test cases are written before the code. Radical, huh?
If you think about it, it makes complete sense. Assuming you are planning to write test cases anyway, it’s no more effort than writing them later. And the big advantage of writing them first?
If you know how you’re going to test it, you write the code to pass first time! Simple really. Simple but inspired.