3 ms·
> Somewhat ironically, our conversation here highlights why it is important. If you initially tested these three lines of code to your satisfaction and didn't f
by flukus 10y ago
> Somewhat ironically, our conversation here highlights why it is important. If you initially tested these three lines of code to your satisfaction and didn't find the bug, how could you assume that your unit tests would catch the bug?
If you can't define the behavior for such a simple function how are they supposed to know if it's working or not? Several posts later you still haven't. Is foo meant to append to the array? Is it meant to initialize a new one? Is it meant to create one if it's null?
- dTal 10y agoEh, I'll give falcolas a pass on that, since the intended behaviour is clearly what any normal person looking at that would think it does - if you wanted to make some sort of closure, I'd hope you'd do it more explicitly (though my opinion of good style and what's supposedly "Pythonic" are often at odds - the whole "[].append()" idiom seems perverse to me). It's not necessarily unreasonable to present technically valid code and say "find the bug" - in C for example you might see "if(x=3)" and conclude, on the basis of what's idiomatic, that it's probably an error.
- flukus 10y ago> since the intended behaviour is clearly what any normal person looking at that would think it does The function is called foo, any normal person would say "wtf is that supposed to do?".