GitHub's search is pretty interesting: every time I refresh the search page it shows a different number of results: 18,401,830; 17,751,631; 15,995,799. Which is anyways quite a lot of results, but then this search finds ThisShouldNeverHappenException , the string "this should never happen" and stuff like // *This* gets run before every test. if (b > d) { fail("XX *should never happen*"); } With quotations it's only a…
This should never happen
31–40 of 214 posts
Re: This should never happen
#32if happens: print "shit, that wasn't supposed to happen"
Re: This should never happen
#33GitHub's search is pretty interesting: every time I refresh the search page it shows a different number of results: 18,401,830; 17,751,631; 15,995,799. Which is anyways quite a lot of results, but then this search finds ThisShouldNeverHappenException , the string "this should never happen" and stuff like // *This* gets run before every test. if (b > d) { fail("XX *should never happen*"); } With quotations it's only a…
Re: This should never happen
#34My initial reaction was "oh no" but as I thought about it, this explicitly indicates that the programmer actually thought about a case.
And is it any different than what most of us do in our unit tests? If we're expecting an exception that isn't thrown or the wrong exception is thrown, we force a test failure.
One of the goals our team is working towards is more robust and complete metric and log collection. We specifically want to capture exceptions that make it to the application server for analysis, but this assumes that the developer has a) considered all cases and b) caught intermediate exceptions and continued processing (or abort).
Re: This should never happen
#35http://www.slideshare.net/bsotomay/uchicago-cmsc-23300-the-b...
Re: This should never happen
#36C++ 2.4M C 400K Java 150K ...
Sounds about right.
Re: This should never happen
#37My 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...
Not just Java. I've seen similar classes in C++ and C# to indicate things which should never occur/are clearly bad programmer mistakes/... Think InternalErrorException/DevFailedError etc. Sometimes it's just a sane thing to do, and using such names means you don't need to write the dreaded 'should never happen' comment manually anymore.
https://msdn.microsoft.com/en-us/library/system.invalidopera...
Re: This should never happen
#38E.g. "Should not happen — probably a bug in Apache Commons Math?"
Or "Shouldn't really happen, barring compiler bugs or cosmic rays"
As they told us, there is no such thing as probability of zero.
Re: This should never happen
#39Earlier quoted context omitted.
I remind myself frequently not to swear in code as I am quite juvenile on a normal day. If I'm struggling I'll just make up a word, so that if it ever happens that someone else sees it I can say it is an acronym but that I have conveniently forgotten for what.
You could always put a "this should never happen" right before the swear words so they know it wasn't your fault.
and so on. Still it would be a change from writing bad code.