Extra special check



  • This was found the other day in part of the code that's in production
    for a large financial company.  Although it's not wrong or buggy
    it did make us wonder who on earth wrote it and gave us all a good
    laugh.  Perhaps they wanted to be extra specially sure it was
    correct or something.



    Lets check if the recordset is at the end of the file, or if it isn't,
    or if it isn't not and the not end of file doesn't equal false.......
    One of them.



    <font color="blue">if</font><font color="black">(((</font><font color="gray">rsMClientPaymentArrangement</font><font color="black">.</font><font color="#880000">IsEOF</font><font color="black">() == </font><font color="#a000a0">FALSE</font><font color="black">) == </font><font color="#a000a0">TRUE</font><font color="black">) != </font><font color="#a000a0">FALSE</font><font color="black">)



    </font>



  • LOL!

    Obviously a case of obscuring the code :P



  • <font style="font-family: verdana;" size="1">@firewireguy said:

    This was found the other day in part of the code that's in production
    for a large financial company.  Although it's not wrong or buggy
    it did make us wonder who on earth wrote it and gave us all a good
    laugh.  Perhaps they wanted to be extra specially sure it was
    correct or something.


    Lets check if the recordset is at the end of the file, or if it isn't,
    or if it isn't not and the not end of file doesn't equal false.......
    One of them.



    </font>

    <font style="font-family: verdana;" color="blue" size="1">if</font><font style="font-family: verdana;" color="black" size="1">(((</font><font style="font-family: verdana;" color="gray" size="1">rsMClientPaymentArrangement</font><font style="font-family: verdana;" color="black" size="1">.</font><font style="font-family: verdana;" color="#880000" size="1">IsEOF</font><font style="font-family: verdana;" color="black" size="1">() == </font><font style="font-family: verdana;" color="#a000a0" size="1">FALSE</font><font style="font-family: verdana;" color="black" size="1">) == </font><font style="font-family: verdana;" color="#a000a0" size="1">TRUE</font><font style="font-family: verdana;" color="black" size="1">) != </font><font style="font-family: verdana;" color="#a000a0" size="1">FALSE</font><font style="font-family: verdana;" color="black" size="1">)



    </font><font style="font-family: verdana;" size="1">

    </font>



    <font size="2">Is it just me, or does this actually do the opposite of what it looks like it was intended to do?  In other words, returns </font><font style="font-family: verdana;" color="gray" size="2">!rsMClientPaymentArrangement</font><font style="font-family: verdana;" color="black" size="2">.</font><font style="font-family: verdana;" color="#880000" size="2">IsEOF</font><font style="font-family: verdana;" color="black" size="1"><font size="2">() ?



    </font>
    </font>



  • yup! :D



  • I'll add that it is correct functionality.  As I said before, it's not buggy, just "creative"!



  • @firewireguy said:

    This was found the other day in part of the code that's in production
    for a large financial company.  Although it's not wrong or buggy
    it did make us wonder who on earth wrote it and gave us all a good
    laugh.  Perhaps they wanted to be extra specially sure it was
    correct or something.



    Lets check if the recordset is at the end of the file, or if it isn't,
    or if it isn't not and the not end of file doesn't equal false.......
    One of them.



    <font color="blue">if</font><font color="black">(((</font><font color="gray">rsMClientPaymentArrangement</font><font color="black">.</font><font color="#880000">IsEOF</font><font color="black">() == </font><font color="#a000a0">FALSE</font><font color="black">) == </font><font color="#a000a0">TRUE</font><font color="black">) != </font><font color="#a000a0">FALSE</font><font color="black">)



    </font>


    What do you mean its not buggy?
    it SHOULD be
    <font color="blue">if</font><font color="black">(isTrue(((</font><font color="gray">rsMClientPaymentArrangement</font><font color="black">.</font><font color="#880000">IsEOF</font><font color="black">() == </font><font color="#a000a0">FALSE</font><font color="black">) == </font><font color="#a000a0">TRUE</font><font color="black">) != </font><font color="#a000a0">FALSE</font><font color="black">) != </font><font color="black"></font><font color="#a000a0">FALSE</font><font color="black">)</font>



  • Umm...yeah...  that hurts to look at...

    Much prettier if you'd just do if(!rs.IsEOF()), but what's the fun in that?



  • @danielpitts said:

    @firewireguy said:
    This was found the other day in part of the code that's in production
    for a large financial company.  Although it's not wrong or buggy
    it did make us wonder who on earth wrote it and gave us all a good
    laugh.  Perhaps they wanted to be extra specially sure it was
    correct or something.



    Lets check if the recordset is at the end of the file, or if it isn't,
    or if it isn't not and the not end of file doesn't equal false.......
    One of them.



    <font color="blue">if</font><font color="black">(((</font><font color="gray">rsMClientPaymentArrangement</font><font color="black">.</font><font color="#880000">IsEOF</font><font color="black">() == </font><font color="#a000a0">FALSE</font><font color="black">) == </font><font color="#a000a0">TRUE</font><font color="black">) != </font><font color="#a000a0">FALSE</font><font color="black">)



    </font>


    What do you mean its not buggy?
    it SHOULD be
    <font color="blue">if</font><font color="black">(isTrue(((</font><font color="gray">rsMClientPaymentArrangement</font><font color="black">.</font><font color="#880000">IsEOF</font><font color="black">() == </font><font color="#a000a0">FALSE</font><font color="black">) == </font><font color="#a000a0">TRUE</font><font color="black">) != </font><font color="#a000a0">FALSE</font><font color="black">) != </font><font color="black"></font><font color="#a000a0">FALSE</font><font color="black">)</font>


    Maybe it should be more like this:

    <font color="blue">if</font><font color="black">(isTrue((((</font><font color="gray">rsMClientPaymentArrangement</font><font color="black">.</font><font color="#880000">IsEOF</font><font color="black">() == </font><font color="#a000a0">FALSE</font><font color="black">) == </font><font color="#a000a0">TRUE</font><font color="black">) != </font><font color="#a000a0">FALSE</font><font color="black">) != </font><font color="black"></font><font color="#a000a0">FILE_NOT_FOUND</font><font color="black">) </font><font color="black">!= </font><font color="black"></font><font color="#a000a0">NOT_TRUE_OR_FALSE</font><font color="black">) </font>
    <font color="black">


    </font>



  • @firewireguy said:

    Perhaps they wanted to be extra specially sure it was
    correct or something.<font color="black">

    </font>




    The ironic thing is, this more complex version of
    if(rsMClientPaymentArrangement.IsEOF()) is actually more likely to be
    wrong, since it's more complex; I had to look at it for a second to
    make sure that the extra checks really were no-ops.



  • O@jesuswaffle said:

    @firewireguy said:
    Perhaps they wanted to be extra specially sure it was
    correct or something.<font color="black">

    </font>




    The ironic thing is, this more complex version of
    if(rsMClientPaymentArrangement.IsEOF()) is actually more likely to be
    wrong, since it's more complex; I had to look at it for a second to
    make sure that the extra checks really were no-ops.


    Oops! I had the logic reversed, too!



  • I don't know why, but somehow I suspect this is a case of the
    "Disgruntled Programmer Syndrome". I can vividly picture in my mind
    some PHB repeatedly reminding the coder to "make extra sure this
    condition is satisfied" thereby provoking the inception of this after
    the first half dozen reminders or so...



  • @lizardfoot said:


    Maybe it should be more like this:

    <font color="blue">if</font><font color="black">(isTrue((((</font><font color="gray">rsMClientPaymentArrangement</font><font color="black">.</font><font color="#880000">IsEOF</font><font color="black">() == </font><font color="#a000a0">FALSE</font><font color="black">) == </font><font color="#a000a0">TRUE</font><font color="black">) != </font><font color="#a000a0">FALSE</font><font color="black">) != </font><font color="black"></font><font color="#a000a0">FILE_NOT_FOUND</font><font color="black">) </font><font color="black">!= </font><font color="black"></font><font color="#a000a0">NOT_TRUE_OR_FALSE</font><font color="black">) </font><font color="black">
    </font>

    That's way more enterprise.


Log in to reply