Test-driven development (TDD)
TDD is a method of developing software that states that you should write a test before writing the actual code. So, you invert your development flow by following the Red-Green-Refactor technique.
What is Red-Green-Refactor?
It goes like this:
- You write a failing test (red).
- You write just enough code to make your test pass (green).
- You refactor that code to improve the design by ensuring that all of the tests are still passing.
Okay, but what does refactoring mean?
I'd define refactoring as (continually) improving the code without changing its behavior.
Having an automated test suite should help you achieve that goal and should help you discover when you break something. No matter whether you do TDD or not, I do recommend refactoring as often as possible; this helps clean your codebase, and it should also help you get rid of some technical debt at the same time.
Okay, but what is technical debt?
Technical debt...