3 ms·
+1. "Don't write bugs" is pretty much the 4Head response to a programmer asking "How do I not write buggy code?" > if you're aware of ways that your code will
by omegalulw 5y ago
+1. "Don't write bugs" is pretty much the 4Head response to a programmer asking "How do I not write buggy code?"
> if you're aware of ways that your code will fail in edge cases, handle those edge cases.
Another key point I want to add is that for every method you write, you should carefully audit the domain of your input and only accept information necessary for your method to work. That way you don't handle edge cases not relevant to your method. The exception probably here is critical edge cases that will SIGSEV, SIGILL, etc and kill your whole process. You usually want to check those - and if you are having to do that frequently that's code smell.