A classic: It's Impossible!



  • Today while doing my daily "bang-head-against-wall" work, I came accross this little classic.

     

    if (k == 0) {
    System.out.println("It's impossible!");
    } else {
    ...
    }

     

    What's even better, that the developer also prints a message to the stdout so that in the event that the impossible happens, you get to know that it's impossible.


    - Brill 



  • Merely improbable.



  • Someone oughta introduce this guy to assert()



  • My favorite in this vein - possibly something I saw on this site - was an error message that read "Bill said this would never happen."



  • Inconceivable!



  • Could this have been within a method in which some variable is to be divided by k?

    Of course in that case the message is not very informative... (as in: not informative at all)



  • This isn't that strange. The coder might think it is impossible for k to be zero at that point, but they realize that what they think is impossible and what actually is impossible may be different. If they are right then that println will never be run, no harm done. But if they are wrong then the println assures they will find out soon enough which may save a whole load of debugging.

     



  • I really hate it when people print out error messages without any real information. As the developer, if I know enough to print out an error message, then I also know specifically what went wrong and why. Since errors are (supposed to be) the exception and not the rule, I tend to dump as much explanatory info and related variables for context as possible - makes finding and fixing the problem a whole lot easier on the next person (IMHO)



  • It's more important to make exceptional error messages like this unique rather than explainatory. The full detailed explaination can always be put as a comment in the code as an alternative to printing it out.

     



  • @Cap'n Steve said:

    Inconceivable!

    You keep using that word. I do not think it means what you think it means.



  • @Cthulhu said:

    This isn't that strange. The coder might think it is impossible for k to be zero at that point, but they realize that what they think is impossible and what actually is impossible may be different. If they are right then that println will never be run, no harm done. But if they are wrong then the println assures they will find out soon enough which may save a whole load of debugging.

     

    That doesn't wash with me... we're supposed to be professionals and a simple unit test would have proven that it couldn't/could happen.

    Whats worse is that nothing is done about it except to print a statement saying it's impossible. 

    the following code would give you the same logic:

    if (k != 0) {
        ...
    }
     
    If I wasn't so lazy I'd have back tracked who added this code to the repository... so at least so I could show them that it made it onto the Daily WTF.

    Alas, I am lazy...


  • I remember in my Java II class how an example the teacher gave us had similar code (it caught an error and then used JOptionPane.showDialog() to say that it was impossiable, that you shouldn't be seeing this) and I managed to get to that error and see the dialog pane in action and e-mailed my instructor (online class) about how I reached that error. Granted, it was something no one would do on purpose (unless it's like those people who have fun checking for insanity checks) but it could happen and when it did, nothing was done with the error.



  • @Manni said:

    @Cap'n Steve said:

    Inconceivable!

    You keep using that word. I do not think it means what you think it means.

    You killed my father. Prepare to die.



  • @savar said:

    @Manni said:

    @Cap'n Steve said:

    Inconceivable!

    You keep using that word. I do not think it means what you think it means.

    You killed my father. Prepare to die.

     

    You be careful. People in masks cannot be trusted.



  • @Harsh said:

    @savar said:
    @Manni said:

    @Cap'n Steve said:

    Inconceivable!

    You keep using that word. I do not think it means what you think it means.

    You killed my father. Prepare to die.

     
    You be careful. People in masks cannot be trusted.

    You mean you'll put down your rock, and I'll put down my sword, and we'll try and kill each other like civilized people? 



  • @brill said:

    If I wasn't so lazy I'd have back tracked who added this code to the repository... so at least so I could show them that it made it onto the Daily WTF.

    Alas, I am lazy...

    That's why SVN blame is so cute. ;) 


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.