Live data from Hacker News

This should never happen

github.com

41–50 of 214 posts

Re: This should never happen

#45
post #4

if happens: print "shit, that wasn't supposed to happen"

Never ever EVER put bad language in any unexpected error cases or logs - even as you're developing it... it WILL somehow magically make its way to production, and it WILL appear!

Not only will it manifest itself in production, it will do so at the time and with the user most likely to cause great embarrassment.

[NB There is a related phenomena to do with a demo of a system that includes "adult content" (i.e. porn) - the likelihood of a user randomly stumbling upon this content is practically 100%, even if this content is a tiny part of the overall demo].

Re: This should never happen

#46

Using github to search like this reminds me of how a CS professor of mine would show the "best commit messages of the year" (homework was submitted via git) by looking for various patterns like all caps, all symbols, etc. http://www.slideshare.net/bsotomay/uchicago-cmsc-23300-the-b...

This is amazing.

Re: This should never happen

#47
call error("in omatch: can't happen"); - Line from omatch routine on pg. 146 [1].

Snips from discussion in [1]: "We can expect problems, therefore, and should prepare for them. ... Garbage is bad enough, but garbage which is expected to contain a count to tell you how long it is can be much worse. ... The first time we ran this code it said 'can't happen' We got that message perhaps a hundred times in the process of adding the rest of the code... This experience speaks for itself; if you're going to walk a high-wire, use a net."

'Can't happen' is as much a pattern as 'Hello, World'... and it has the same genesis.

[1] Brian Kernighan, P.J. Plauger, 'Software Tools', Addison-Wesley 1976

Re: This should never happen

#48

My favorite part is the Java project that has an exception class called ThisShouldNeverHappenException [1]. Only in Java would someone create an exception class for a condition that should never happen :) [1] https://github.com/TheProjecter/propidle/blob/f0d5320e2a3d46...

There's http://docs.oracle.com/javase/6/docs/api/java/lang/IllegalSt... that could be used in this case.
Post reply on HN