• OMGWTFJON (unregistered)

    I hate "if constant < variable" constructs. It's totally backwards to intuition. About the only place I ever tolerate it is if there's a possibility a String is null, in which case "if("THAT".equals(something))" at least has brevity over "if(something != null && something.equals("THAT"))"

    But still. Why use it with a variable and 0???

  • Ken Bloom (unregistered)

    Using a for loop would be idiomatic in some languages (specifically Scala, if the result set was a monad)

  • ec (unregistered)

    Let spring take care of the connection mgmt. I would take each of those queries and make a spring query object for each one! now that's a real WTF

  • Monica Lewinsky (unregistered)

    I have swallowed the beast...

    "Considering the current sad state of our computer programs, software development is clearly still a black art, and cannot yet be called an engineering discipline." -Bill Clinton

  • Henning Makholm (unregistered) in reply to Mason Wheeler
    Mason Wheeler:
    "if ( ( 0 <= index ) && ( index < size ) )"? What's the deal with that && sign anyway? Why can't you say "if ( ( 0 <= index ) & ( index < size ) )"? Because when numbers can be booleans, the compiler can't tell whether your and, or, xor or [b]not[b] is supposed to be operating on a number or on a boolean value, so you need to have separate, explicit "logical" and "bitwise" versions of each, and heaven help you if you get the two versions conflated.

    Even to this day Java and C#, which actually have real boolean types, require you to keep two sets of operators straight, simply because that's the way C did it almost 40 years ago.

    On the contrary: somewhen in the early prehistory of C (but I forget whether it was in the BCPL or B phase), there was only & and |, which were used for bitwise as well as Boolean operations. That is why they come at such strange a place in the precedence order. It made sense when you could write things like a<b & b<c or x==1 | x==2 without parentheses.

    The new feature for which && and || was introduced was not that they worked for Booleans but that they short-circuit the evaluation order. The short-circuiting behavior is still highly relevant today.

    It is not inconceivable for a language to have a single set of operators, whose evaluation-order properties differ according to which types they are used in (Pascal is an example), but I daresay it doesn't make the language prettier.

  • caper (unregistered)

    How can a row count ever return a negative number ?

    This code always falls to the bottom and returns true.

  • Ouch! (unregistered) in reply to caper
    caper:
    How can a row count ever return a negative number ?
    Integer overflow.
    This code always falls to the bottom and returns true.
    Nope, sometimes the row count will be 0.
  • caper (unregistered)

    My mistake. I saw "(0 < count)" and thought "(count < 0)".

  • hellop (unregistered) in reply to Mister Cheese

    Except that you're wrong.

    At the end of the original code: if (0 < count) return false;

    	available = true;
    } catch (Exception e) {
    	logger.error("isWidgetAvailable", e);
    }
    
    return available;
    

    }

    As you can see, if after any query "count" is greater than zero, it returns false. So, it doesn't return try if it finds a matching row, it returns false. It only returns true if it finds nothing. And, therefore you are wrong on the Internet.

  • Omego2K (unregistered) in reply to The Nerve

    Does anybody else see that besides the obvious issues that the select statement could just be one with all those tables joined on the widgetId?

Leave a comment on “Swallowed by the Beast”

Log In or post as a guest

Replying to comment #:

« Return to Article