Surprisingly, there’s many programmers who still don’t know what Test-driven development (TDD) is. I think it’s a very important practice that all of us should follow, since it produces software with many less bugs.

TDD is a programming methodology that involves two other practices: test first development, and refactoring. First a set of unit tests is written and verified to fail. Then, code to make them pass must be written, and lastly this code is refactored. The aim of TDD is to achieve clean code that works. The main idea around this methodology is that requirements must be translated into automated tests: thus, when these tests pass, all requirements are guaranteed to have been accomplished. The application to be developed must be flexible enough to allow automated tests to be run. Each test should be small enough to exactly determine which piece of code is failing.

Read the rest of this entry »