Lottery Fallacy

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Lottery Fallacy

OmegaKV
A person might feel a sense of regret upon picking the wrong numbers in a lottery. But there is no reason for this regret, because before the lottery numbers were drawn, there was no way to figure out what the right numbers were.

The same kind of thing applies to unit testing for trying to predict problems for a new script you write. Successfully speculating about the kind of bugs you will have is rare, like winning the lottery, which means that writing tests as a precautionary measure is not worth the effort. But what makes the idea of writings unit tests seductive is that after the fact, whenever X goes wrong, you can always say "this wouldn't have happened if you had written a unit test that tests for X!". And so the entire software world is forced to spend an enormous amount of time speculating about potential problems and writing unit tests because of this fallacy.

To see the fallacy in action just look at all the responses to this comment on reddit:

https://old.reddit.com/r/AskReddit/comments/ze76ah/whats_the_worst_mistake_youve_seen_someone_do_in/iz6elze/

Saying "this wouldn't have happened if you had written a unit test that tests for X!", is like saying "You would have won the lottery if you had picked numbers XYZ".
Reply | Threaded
Open this post in threaded view
|

Re: Lottery Fallacy

fschmidt
Administrator
I wrote a post a long time ago against unit testing, but I can't find it now.  Anyway, my thinking has changed and I understand now why modern scum love unit testing.  It appeals to all of their worst values.  They love complexity and reductionism.  I haven't talked much about reductionism, but it is one of the major sins of modern culture.  Good religion encourages holistic thinking, and I think that a program should be viewed holistically.

I used to support functional testing, but now I don't even bother with that.  A good simple program will fail quickly if there is a bug.  So I just fix all bugs quickly, no matter how small.  When I release new code, I just watch the logs for errors for a short time.  That is good enough.
RSF
Reply | Threaded
Open this post in threaded view
|

Re: Lottery Fallacy

RSF
I have never written any tests, but I assumed that it was because I am not traditionally trained.