3 ms·
Hmmm, seems like pretty dubious advice: So by all means, test your code with the force -- brute force! It's good stuff! Just be careful not to get sloppy, and l
by michael_dorfman 17y ago
Hmmm, seems like pretty dubious advice:
So by all means, test your code with the force -- brute force! It's good stuff! Just be careful not to get sloppy, and let the dark side of the testing force prevail. If you think one or two simple test cases covers it, that's taking the easy (and most likely, buggy and incorrect) way out.
Unfortunately, the example he gives is the epitome of "sloppy"-- in fact, it represents a total refusal to even attempt to understand the task at hand before beginning coding. Obviously, having a large suite of test cases is an advantage; but it's no substitute for understanding what one is trying to accomplish.
- fogus 17y agoJeff Atwood wants a pile of tests without understanding -- Rich Hickey wants total understanding without tests... Where is the middle ground?
- michael_dorfman 17y agoWell, if you have total understanding you probably don't need tests, but most of us (Knuth excepted, apparently) don't get to that level. So, the middle ground is: understand as much as you can, test as much as you have to.
- eru 17y ago"Beware of bugs in the above code; I have only proved it correct, not tried it." - Donald Knuth > So, the middle ground is: understand as much as you can, test as much as you have to. Test even what you understand. QuickCheck (http://www.cs.chalmers.se/~rjmh/QuickCheck/ http://www.cs.chalmers.se/~rjmh/QuickCheck/) and friends like SmallCheck and Lazy SmallCheck let you turn specs into tests easily.