Range-Checking (not)
-
I kid you not - genuinely found in production code. Has raised a smile or two in our office.
If flag < 1 And flag > 3 Then Exit Function
That's actually not the worst problem with the code, but definitely the funniest.
-
I kid you not - genuinely found in production code. Has raised a smile or two in our office.
If flag < 1 And flag > 3 Then Exit Function
That's actually not the worst problem with the code, but definitely the funniest.
Methinks the guy who works for my company has a sibling who works for yours. :rolleyes: Though, if "flag" is a delayed computation with overridden operators, that could actually turn out to be true (e.g., square root of 100 is both positive and negative 10). ;P
-
Methinks the guy who works for my company has a sibling who works for yours. :rolleyes: Though, if "flag" is a delayed computation with overridden operators, that could actually turn out to be true (e.g., square root of 100 is both positive and negative 10). ;P
-
Your post the other day was part of my inspiration for my point about the square root of a number... so you're partly to blame for my silliness! :)
-
Methinks the guy who works for my company has a sibling who works for yours. :rolleyes: Though, if "flag" is a delayed computation with overridden operators, that could actually turn out to be true (e.g., square root of 100 is both positive and negative 10). ;P
That was one of the reasons I immediately posted it - the coincidence of seeing yours so recently. I almost wish there was something clever like that going on, but no, flag is declared as an Integer. As DD pointed out though, even if that was the case its still a horror. I'm coming round to the view that operator overloading maybe a bad idea because of the potential for abuses like this. Although I note that D provides a better implementation, where defining opCmp covers the whole family of <, <= etc. preventing abuses like that (to an extent).
-
That was one of the reasons I immediately posted it - the coincidence of seeing yours so recently. I almost wish there was something clever like that going on, but no, flag is declared as an Integer. As DD pointed out though, even if that was the case its still a horror. I'm coming round to the view that operator overloading maybe a bad idea because of the potential for abuses like this. Although I note that D provides a better implementation, where defining opCmp covers the whole family of <, <= etc. preventing abuses like that (to an extent).
I unfortunately must disagree.. no amount of language feature or design constraint can save you from a programmer lacking in programming skills. The only solution for THAT problem is good code review and a team willing to point out ways to improve (and enforce them) to the souls who are in this occupation but shouldn't be. And.. your original post is hilarious and sad at the same time. For the same reasons.