4 ms·
>Why would tests make this code more likely? Code like this is basically only possible through testing, because the programmer doesn't understand why it is wor
by logicallee 9y ago
>Why would tests make this code more likely?
Code like this is basically only possible through testing, because the programmer doesn't understand why it is working: it says so in the comment, which I believe.
So if it weren't written against testing (manual or automatic) it simply couldn't be written like this.
There are a lot of really broken designs that "work". Testing gets you "working" code. Often you could do much better starting with correct code and then adding testing afterward - which I believe is not the essence of TDD. TDD is about driving the writing of code by tests, and I believe the example I shared is one of these bad outcomes. (There are others.)