4 ms·
Maybe it's not "real world" to have to implement a simple but serious algorithm in a few lines. I don't think the parent was objecting to implementing a simple
by abstractbill 17y ago
Maybe it's not "real world" to have to implement a simple but serious algorithm in a few lines.
I don't think the parent was objecting to implementing a simple but serious algorithm in a few lines, but to doing so without performing any testing at all.
There is still some hard stuff that needs to be done, though.
Yes, and I'm pretty sure the people doing that hard stuff do some testing ;)
- FutureNerd 17y agoGoing back to Bentley, the point was not to code without testing but whether you could think through a small piece of code <i>before</i> testing. raganwald says, "It feels very retrograde to try to write the whole thing out and only then start thinking about [...] edge cases." Nobody said you had to write it before thinking about edge cases! The idea is to think about the edge cases and incorporate that thinking into the code before you actually test the code--whether you can be--actually whether you know the steps to be--that thorough in your head. One way to think about edge cases, of course, is to write the test code before the function. But after writing the tests, try writing the function correctly before testing it. Of course, one of the potential bugs in binary search doesn't occur to people before they write and then try it. And, that bug is hard to test for, ahem, don't want to explain why.