←back to thread

475 points danielstocks | 2 comments | | HN request time: 0.001s | source
Show context
henvic ◴[] No.27304014[source]
As a software engineer, I hate when I add a check for something "that will never happen" but that if happens is awful, and people complain.

A classic example: you need to get a user from a session, check against a database, and continue if they're signed in.

Then I add a simple if databaseUser.Username != form.Username and people will say "if that happens we've something worse wrong". Geez, something might be wrong and such double checking might provide to be useful.

On a smaller scale, bits flip due to cosmic rays and so on. Of course, there must be a limit where we stop, but people are used to actively avoid doing such "silly assertions" even for important steps.

¯\_(ツ)_/¯

replies(9): >>27304123 #>>27304382 #>>27304569 #>>27304654 #>>27304687 #>>27304894 #>>27308296 #>>27308719 #>>27309906 #
bagacrap ◴[] No.27304123[source]
it's fine to make the check but I hope you don't sweep it under the rug with an early out without at least logging the occurrence
replies(1): >>27304171 #
1. henvic ◴[] No.27304171[source]
uh? Why would you make the check, find a critical internal inconsistency, and skip logging it? :)
replies(1): >>27304387 #
2. dsego ◴[] No.27304387[source]
log("this should never happen")