Write Your Tests First
Test-driven development (TDD) is a software development technique that uses really short development cycles to incrementally design your software.
Here’s how it works:
Red: Before you write any new code for the system, you first write a failing unit test, showing the intent of what you would like the new code to do. Here you are thinking critically about the design.
Green: Then you do whatever it takes to make the test pass. If you see the full implementation, add the new code. If you don’t, do just enough to get the test to pass.
Refactor: Then you go back and clean up any code or sins you committed while trying to get the test to pass. Here you are removing duplication and making sure everything is lean, mean, ...