A look at testing: Finding the effect closer to the cause
This is the number one reason I appreciate testing my code: It allows me to figure out the effects of my code while I am writing it.
I think this particular reason is accentuated for me because I have an absolutely horrid memory. After I've written code I generally forget all of the reasons behind why I did it a certain way. So if I am told that some code I wrote caused a bug that I did not foresee, in some other place in the codebase, then I need to go back and figure out everything I was trying to do while writing the buggy code and try to fix the bug that it caused.
Testing benefits this situation in two distinctive ways.
1) It helps me find that obscure problem somewhere else in the code that my code caused because I can run the tests for that obscure area of the code and get immediate feedback about whether or not I broke anything.
2) If, for some reason, the tests for that obscure area of the code do not alert me to the problem, I have now written extensive tests for my area of the code. This way my tests will tell me if I break anything with my original code while trying to fix the bug.
I can not tell you how many times #2 has helped me. Even when I am writing my own code I find myself creating bugs in areas of the code that I wrote a day before. The fact of the matter is that code gets complicated fast and it is very difficult/impossible to keep all of the ins and outs of your code straight. Testing is a lifesaver in this regard.
I think this particular reason is accentuated for me because I have an absolutely horrid memory. After I've written code I generally forget all of the reasons behind why I did it a certain way. So if I am told that some code I wrote caused a bug that I did not foresee, in some other place in the codebase, then I need to go back and figure out everything I was trying to do while writing the buggy code and try to fix the bug that it caused.
Testing benefits this situation in two distinctive ways.
1) It helps me find that obscure problem somewhere else in the code that my code caused because I can run the tests for that obscure area of the code and get immediate feedback about whether or not I broke anything.
2) If, for some reason, the tests for that obscure area of the code do not alert me to the problem, I have now written extensive tests for my area of the code. This way my tests will tell me if I break anything with my original code while trying to fix the bug.
I can not tell you how many times #2 has helped me. Even when I am writing my own code I find myself creating bugs in areas of the code that I wrote a day before. The fact of the matter is that code gets complicated fast and it is very difficult/impossible to keep all of the ins and outs of your code straight. Testing is a lifesaver in this regard.

0 Comments:
Post a Comment
<< Home