Test Driven Development, or TDD, is a practice used by computer programmers to approach the development of code from a very structured, linear perspective. The goal of TDD is to write code that tests your code. Yeah, think about that for a sec. Said differently, it is a program (or suite of tests) that wraps around your code and validates that your code does what you expect it to do.
The first steps in TDD are so simple that they almost seem difficult, especially for a beginner programmer. There is an interesting struggle between doing TDD and your own developing 'code-ego'. TDD forces you to write code that you know is technically correct, but so narrow in scope that it is wrong. Your ego screams 'I know the answer! What are you doing? Danger, danger! Bad code!'.
But you stick at it and you work really hard not to cheat and write fully functional code. Baby steps, baby steps. Red, Green, Refactor. Rinse and repeat.
But, in the beginning, the inner code cowboy wins a lot and you find that you do cheat. And if you are committed to the process, you delete that beautiful, apparently fully functioning code and you hardcode a method return. And it kinda hurts the first few times. "Why am I deleting good code?"
Because thats TDD!
When you get into a good rhythm you and you begin to watch a program take shape, when developed using TDD methodology, you start to get it. Hmmmmm. Maybe writing kindergarten code first will actually lead to a stronger program? Huh. I think so.
TDD is drafting a blueprint before buying lumber and hiring builders. It's a map to your final code and, once you get it, you GET it. It's a new tool in my toolbox. Well, probably on my tool belt. I need constant access to this one!
Cheers.
No comments:
Post a Comment