This tweet by Kent Beck explains perfectly why I use TDD.
When I was first introduced to TDD and Unit Testing, I was blown away by the fact that I had never thought of writing code to test my other code. I would write code and run the entire application to see if the changes I made worked correctly. I would test the happy path and then pass it on to QA for more verification. I knew that I didn't find all of the bugs in the code, but I also wasn't sure what more I could do to find them. I hated when I got bugs back from QA and worse when the customer found a bug.
I have the anxiety Kent is talking about. It was pretty stressful to deal with this anxiety as I wrote code not knowing how I was going to mess up this time. I would fix something only to introduce a new issue or cause a previously fixed problem to resurface. Then I learned about Unit Tests and TDD and I had a way to alleviate that anxiety. If I was fixing a bug, I could write a few tests that would make sure that bug would not reappear. I could write new code having at least some level of confidence that it would do what I expected it to do.
TDD became my anti-anxiety medicine. It made my code better. It allowed me to relax more about my code. I've often wondered why others didn't seem as interested in TDD as I am, perhaps it is as simple as they don't feel the same anxiety I feel.
what if the problem with TDD is that it is adapted to address a level of anxiety most people just don't experience?
— Kent Beck (@KentBeck) November 19, 2015
When I was first introduced to TDD and Unit Testing, I was blown away by the fact that I had never thought of writing code to test my other code. I would write code and run the entire application to see if the changes I made worked correctly. I would test the happy path and then pass it on to QA for more verification. I knew that I didn't find all of the bugs in the code, but I also wasn't sure what more I could do to find them. I hated when I got bugs back from QA and worse when the customer found a bug.
I have the anxiety Kent is talking about. It was pretty stressful to deal with this anxiety as I wrote code not knowing how I was going to mess up this time. I would fix something only to introduce a new issue or cause a previously fixed problem to resurface. Then I learned about Unit Tests and TDD and I had a way to alleviate that anxiety. If I was fixing a bug, I could write a few tests that would make sure that bug would not reappear. I could write new code having at least some level of confidence that it would do what I expected it to do.
TDD became my anti-anxiety medicine. It made my code better. It allowed me to relax more about my code. I've often wondered why others didn't seem as interested in TDD as I am, perhaps it is as simple as they don't feel the same anxiety I feel.
Comments
Post a Comment