4 ms·
I’d be concerned, in the presence of widespread sanity checking of these sorts, of the sanity checking code being bad and managing to make things worse. It’s we
by chrismorgan 3y ago
I’d be concerned, in the presence of widespread sanity checking of these sorts, of the sanity checking code being bad and managing to make things worse. It’s well-known that error-checking code is about the buggiest code out there, largely because it’s not well-stressed.
There’s also the problem that it’s not always clear where such sanity checking may be useful, or what should be done if the sanity check fails. A human can recognise something is awry and apply reason to it, seeking confirmation or correction or ignoring the value and tweaking the rest to compensate, or whatever seems reasonable; but software can’t do that unless it’s been explicitly coded in, and, simplifying far beyond the point of strict accuracy, doesn’t make mistakes in calculations so that half of your human error-detection heuristics would be a waste of time and you should just fix the obvious bug. (This is, as I say, a gross oversimplification.)
- wodenokoto 3y agoI worked on a retail pricing system that had a sanity check for prices over 10.000. But once we moved to Japan, that sanity check silently stopped all sorts of items from being processed.
- madsbuch 3y agoThis is a classic localisation issue. When I was younger and worked mostly for Danish companies, we always knew that that a system _could_ be utilised in another locale. as such we always tracked currencies, timezone, etc. Starting to work for American companies all that is out the window. An int with the var name "amount" – of cause that is USD!
- pavel_lishin 3y ago> An int with the var name "amount" – of cause that is USD! Or is it cents? Or fractions of cents? Enjoy digging through the source code and commit history (which may sometimes look like db.prices.old.2022.bak.php) to try and figure out what the answer is! Bonus points if at some point, that changed. Extra bonus points if it didn't change everywhere.
- wodenokoto 3y agoOurs wasn’t called just amount, it was called “amount_usd” and represented the local currency. Fun times!