2 ms·
...I've once had an installer refusing to install the program because I had several GiB of free disk space and obviously disks so large do not exist. Thanks for
by Joker_vD 3y ago
...I've once had an installer refusing to install the program because I had several GiB of free disk space and obviously disks so large do not exist. Thanks for having this sanity check, I guess.
- SilasX 3y agoReminds me of a Reddit submission where the "WalkScore" map assumed rent could never be more than $5000/month: https://imgur.com/2DrlnYH https://imgur.com/2DrlnYH
- ryandrake 3y agoYea, that wasn't a Sanity Check, it was a terrible assumption by the software developer. I think one of the best ways to proactively find bugs in someone's software is to look for 1. declared constants and 2. comments like // this can never happen For 1. constants: Are they really CONSTANTS in the sense that they are immutable laws of the universe? Or are they assumptions you are making to make your program look nice? I can understand declaring pi as a constant or the gravitational constant. Is MAX_DB_RECORD really a constant? OK, so let's say you believe it is--now you just gave yourself tons of "checking" work every time a record is added, and deliberately added bugs in the cases where you don't check. Did you catch them all? Is MAX_HD_SIZE really a constant? For 2. this can never happen: These are the parts of your code that edge cases swarm to, in order to give you all your P3 bugs. Really? It can NEVER happen? If so, why are you logging and doing a stack dump there? A "This can never happen" code block is usually not a sanity check, it's usually a deliberately engineered bug.
- Joker_vD 3y agoWell, most of the code of the 2nd kind that you describe that I've seen had a comment of the "I am almost certain that this condition can occur at this point but I may be wrong; as Knuth once said, 'I've only proven this code correct, haven't actually tried it' so let's add some debug logging, just in case" kind near it which IMHO is an entirely reasonable approach.