4 ms·
Maybe this applies to Go code? Snark aside, I am somebody who is very concerned about edge cases, but those ratios seem completely wrong to me for the kind of
by atq2119 2y ago
Maybe this applies to Go code?
Snark aside, I am somebody who is very concerned about edge cases, but those ratios seem completely wrong to me for the kind of code I write. And perhaps one should say "corner cases" instead of "error cases". Corner cases aren't necessarily errors. What I find is that a good algorithm that is properly "in tune" with the problem space will often implicitly handle corner cases correctly. While an algorithm that was hacked together by somebody who is "coding to the test" without really understanding the problem space tends to not handle corner cases, and then the developer tries to handle them by adding if-statements to patch their handling.
In the end, devoting 70% or 80% of thinking time to corner cases seems entirely plausible to me. 70% or 80% of lines of code dedicated to corner cases may be a smell.
- wduquette 2y agoDepends on the kind of code. If you're automating a process, or handling large quantities of user input, for example, problem cases are everywhere. Or if you're working with a complex problem space where things can compose in unexpected ways (e.g., a language interpreter).