• (cs)

    So, what is the WTF here?

    Do you have a problem with IF ELSE statements?

    Does it bother you that the IF part is the same as the ELSE part?

    Obviously the code used to do something different depending on the value of Request.QueryString("source_url").  The requirements later dictated that the same operation be performed in both circumstances.  The programmer, when making that change, didn't want to cause any unwanted side-effects that might be caused by removing the branch.  The sensible and logical thing to do, in that case, is to simply give both branches the exact same code.

  • (cs)

    Just planning ahead, right? [8-|]

  • Matt B (unregistered) in reply to whoisfred
    whoisfred:
    The programmer, when making that change, didn't want to cause any unwanted side-effects that might be caused by removing the branch.  The sensible and logical thing to do, in that case, is to simply give both branches the exact same code.


    You are obviously joking or you are an idiot

    If it's the former, this sense of humor really isn't that funny.
  • cdog (unregistered) in reply to whoisfred

    Perhaps you could elaborate on "unwanted side-effects that might be caused by removing the branch".  Try as I might, I can't figure out what could go wrong by simply removing the IF ELSE.

  • cdog (unregistered) in reply to cdog

    Or maybe my sarcasm detector is irreparably damaged from all the actual moronic posts... let's hope that's the case.

  • (cs)

    Nice, you take the high road, I'll take the low road....hey we got to the same spot either way!  Jeeeez...

  • (cs) in reply to cdog
    Anonymous:
    Perhaps you could elaborate on "unwanted side-effects that might be caused by removing the branch".  Try as I might, I can't figure out what could go wrong by simply removing the IF ELSE.


    Maybe there was a problem regarding a cache-flush that only occured when an if-then-else statement were in that exact point. But, the more likely case is it as paid by number of lines.
  • (cs) in reply to whoisfred
    whoisfred:
    So, what is the WTF here?

    Do you have a problem with IF ELSE statements?

    Does it bother you that the IF part is the same as the ELSE part?

    Obviously the code used to do something different depending on the value of Request.QueryString("source_url").  The requirements later dictated that the same operation be performed in both circumstances.  The programmer, when making that change, didn't want to cause any unwanted side-effects that might be caused by removing the branch.  The sensible and logical thing to do, in that case, is to simply give both branches the exact same code.


    LOL
  • Brad (unregistered) in reply to Matt B
    Matt B:
    whoisfred:
    The programmer, when making that change, didn't want to cause any unwanted side-effects that might be caused by removing the branch.  The sensible and logical thing to do, in that case, is to simply give both branches the exact same code.


    You are obviously joking or you are an idiot

    If it's the former, this sense of humor really isn't that funny.


    What Matt B said.  The only thing that could be causing a side effect is the Request.QueryString("source_url") call.  If this is an issue, then the call should be made outside the if clause and the branch should still be removed.  There is absolutely no sense in  maintaining two copies of the same code when one will do.

    - B
  • OneFactor (unregistered) in reply to cdog

    Wow.... I was struck speechless for at least a minute there.

    Wonder if this consultant ever thought of nesting these beasts inside one another? [:^)]

  • (cs) in reply to Matt B
    Anonymous:
    whoisfred:
    The programmer, when making that change, didn't want to cause any unwanted side-effects that might be caused by removing the branch.  The sensible and logical thing to do, in that case, is to simply give both branches the exact same code.


    You are obviously joking or you are an idiot

    If it's the former, this sense of humor really isn't that funny.


    So, basically you took time out to say one of two things to me:

    A)  You are an idiot.

      -or-

    B)  You aren't funny.

    Why be so negative?

    This is a place that people are supposed to come to make fun of others not each other!
  • (cs) in reply to Mike R

    Mike R:
    Anonymous:
    Perhaps you could elaborate on "unwanted side-effects that might be caused by removing the branch".  Try as I might, I can't figure out what could go wrong by simply removing the IF ELSE.


    Maybe there was a problem regarding a cache-flush that only occured when an if-then-else statement were in that exact point. But, the more likely case is it as paid by number of lines.

    Do programmers actually get paid by the line?  (cringe...Waits for flame thrower to hit)  I have never actually programmed outside of work before.  I can't see where that would be a good way to do business, on the other hand it could be very profitable...

  • (cs) in reply to Matt B
    Anonymous:
    whoisfred:
    The programmer, when making that change, didn't want to cause any unwanted side-effects that might be caused by removing the branch.  The sensible and logical thing to do, in that case, is to simply give both branches the exact same code.


    You are obviously joking or you are an idiot

    If it's the former, this sense of humor really isn't that funny.

    I laughed.
  • (cs) in reply to cm5400
    cm5400:

    Do programmers actually get paid by the line?  (cringe...Waits for flame thrower to hit)  I have never actually programmed outside of work before.  I can't see where that would be a good way to do business, on the other hand it could be very profitable...



    It would be profitable for the programmer, but  not for the employer.  For the 'by the line' approach to be anything near useful for an employer, the employer would also have to do code reviews to make sure the programmer isn't doing the kind of donkey doo we see here.  But, if you are going to do code reviews, then you can just pay based on merit according to the code reviews.

    I doubt many people, (if any at all) have or do get paid by the line.  I wouldn't be surprised if in the past employers used to base an employees productivity by numbers of lines, but I would hope that most employers have wised up by now and use better methods of determing productivity and program quality.
  • Emmy (unregistered)

    http://www.dba-oracle.com/dress_code.htm - Is this a joke? I don't know anyone who would be willing to live by that dress code. And hello, "All ear hair must be shaved"? Yikes.

  • (cs)

    This is called Best Practices and eXtreme Programming, people: TEST EARLY (first <FONT face="Courier New">if</FONT>...) and TEST OFTEN (<FONT face="Courier New">else</FONT> block).

  • (cs)

    I submitted that WTF and I can tell you that it is based on real code I have been given to maintain, and that the consultant in question was a "professional" VB coder paid by project not by lines of code (does anybody?).

    Plus, this was production code, and the consultant no longer maintains it, so I can asure you that it wasn't an attempt to avoid side-effects while testing, but more likely what I call "Copy Paste Syndrome", or the (incredibly common) "DeMorgan Mutation Disorder", where someone tries to refactor the logic of conditional branching in an attempt to simplify it, and ends up with a disastrous monster that just happens to branch as intended, mostly. :)

        -dZ.

  • (cs) in reply to whoisfred

    whoisfred:
    This is a place that people are supposed to come to make fun of others not each other!

    You must be new to this planet...and when are the pancakes coming?

  • Craig Stuntz (unregistered) in reply to Matt B
    Anonymous:
    You are obviously joking or you are an idiot

    Actually, there's a third possibility: He wrote the code and was paid by the line.
  • Trigger (unregistered)

    <font class="bodyTextMedium">Donald K. Burleson
    </font>
    <font class="bodyTextMedium">Man this dude looks like an Umpa-Lumpa!
    </font>

  • Otto (unregistered) in reply to cm5400
    cm5400:

    Do programmers actually get paid by the line?  (cringe...Waits for flame thrower to hit)  I have never actually programmed outside of work before.  I can't see where that would be a good way to do business, on the other hand it could be very profitable...

    Heck yeah! I'd be coding myself up a Lexus!  [:D]

  • cm5400' Boss (unregistered) in reply to Otto

    Well, now you can begin all over

  • (cs)

    Am I the only one who looks at "&verify=1" and gets an ominous feeling?  I hope that's not a flag put in the URL query string to perform some sort of security or input verification, because if it is, the user could theoretically replace it with "&verify=0" to do an end run around the measures in place. 

    The query string will be visible by the user in their address bar since a response.redirect is being perfomed instead of a server.transfer.  Maybe I'm just paranoid.

     

  • (cs)

    Hah!  You think that's bad, try entire parallel methods!  It's sad, but I've seen it.  On a related note, is it physically possible to read this many books on Oracle much less write them?  And the wife?  With the minature horses

    All in all, that leaves me more speechless than the actual WTF. 

  • ces (unregistered) in reply to rogthefrog

    Brilliant.

  • (cs)

    > People can spot a cheap suit at 300 yards, and so can our clients.

    I like how this implies that their clients are not people.

  • (cs) in reply to cdog

    Anonymous:
    Perhaps you could elaborate on "unwanted side-effects that might be caused by removing the branch".  Try as I might, I can't figure out what could go wrong by simply removing the IF ELSE.

    The End if would get lonely. [:'(]

  • (cs) in reply to whoisfred
    whoisfred:
    cm5400:

    Do programmers actually get paid by the line?  (cringe...Waits for flame thrower to hit)  I have never actually programmed outside of work before.  I can't see where that would be a good way to do business, on the other hand it could be very profitable...



    It would be profitable for the programmer, but  not for the employer.  For the 'by the line' approach to be anything near useful for an employer, the employer would also have to do code reviews to make sure the programmer isn't doing the kind of donkey doo we see here.  But, if you are going to do code reviews, then you can just pay based on merit according to the code reviews.

    I doubt many people, (if any at all) have or do get paid by the line.  I wouldn't be surprised if in the past employers used to base an employees productivity by numbers of lines, but I would hope that most employers have wised up by now and use better methods of determing productivity and program quality.


    If lawyers get paid by the hour and writers and reporters get paid by the word, why couldn't programmers get paid by the line? 
  • Ayende Rahien (unregistered) in reply to cdog
    Anonymous:
    Perhaps you could elaborate on "unwanted side-effects that might be caused by removing the branch".  Try as I might, I can't figure out what could go wrong by simply removing the IF ELSE.


    You aren't thinking deeply enough, this is a highly paid consulant that obviously used complex multi threading in his code, in the case, the evaluation of the IF undoubtly solved some syncronization problem. Doing it any other way is Wrong ;)
  • (cs) in reply to bobday

    bobday:

    If lawyers get paid by the hour and writers and reporters get paid by the word, why couldn't programmers get paid by the line? 

    Imagine all of the loop unrolling that would take place...for performance optimization, of course [:P]

     

  • Anonymous (unregistered)

    When I last saw the dress code, it wasn't nearly as elaborate, and had no illustrations.  Back then, it looked almost legit.

  • (cs) in reply to bobday
    bobday:
    If lawyers get paid by the hour and writers and reporters get paid by the word, why couldn't programmers get paid by the line?

    And this statement is a good example of what is wrong with the world. People don't get paid for doing good work, they get paid for doing what looks like much work.

    The best code I produce, usually take less amount of lines. The more lines the code have, the longer it takes to read it, the greater the chance that there is a bug hidden in it, and the greater the chance that there is duplicated code in it.

  • (cs) in reply to wildclaw

    Seconded.  A much more efficient model would be to pay programmers by the number of times their code executed and did what it was supposed to, minus the number of times their code executed and failed with an error, minus five times the number of times their code executed and failed silently (possibly staggering along long enough to corrupt data.)

  • Anonymous (unregistered) in reply to Maurits

    Can someone tell me WTF is up with the images on this page?  Are they supposed to be Don and the wife or what?

    http://www.dba-oracle.com/art_fun_starwars_movie.htm

  • (cs) in reply to Anonymous
    Anonymous:

    Can someone tell me WTF is up with the images on this page?  Are they supposed to be Don and the wife or what?

    http://www.dba-oracle.com/art_fun_starwars_movie.htm



    Now that's irony - the guy with the rigid, "professional", "females can NEVER wear anything but skirts" website posts photoshopped pictures of himself on said website.  
  • (cs)

    I refactor that to:

    Response.Redirect strRedirect & "&verify=1&process=1"

    In ASP the parens are optional and mostly annoying.  Of course, my code (as the original WTF) assumes that strRedirect already has some querystring, otherwise we need to kill the leading "&".

    Frankly, after spending a lot of time refactoring ASP code, in a corporate IT shop, this is small stuff.  Hardly worth talking about.

    My favorite is when they take every field from an Oracle database and append an empty tring to it so they don't have to deal with NULL.

    It ends up looking like:

    var1 = rs("field1") & ""
    var2 = rs("field2") & ""
    var3 = rs("field3") & ""

    I ran into a lot of that from my old job.

  • (cs)

    There is the possibility that this could be the result of an automated refactoring tool, though even then it's hard to think of a case where this would result unless the automated refactoring tool is badly used.

  • Z (unregistered) in reply to wildclaw
    wildclaw:
    The best code I produce, usually take less amount of lines. The more lines the code have, the longer it takes to read it, the greater the chance that there is a bug hidden in it, and the greater the chance that there is duplicated code in it.


    As Edsger Dijkstra put it, one should not measure lines of code produced by a programmer, but lines of code spent.
  • Raw (unregistered) in reply to dfinster

    dfinster:
    My favorite is when they take every field from an Oracle database and append an empty tring to it so they don't have to deal with NULL.

    It ends up looking like:

    var1 = rs("field1") & ""
    var2 = rs("field2") & ""
    var3 = rs("field3") & ""

    I ran into a lot of that from my old job.

     

    Actually, I've seen that and there is a reason. Due to some wierd bug in ADO, you sometimes get intermittent errors if you don't do that. For some reason, it is not the null values that screw things up, it is usually if there are several long strings in one record, and adding a nonsense empty string for some wierd reason fixes it. It is one of those really wierd Heisenbugs that don't appear when you singlestep through the code, just when it is run normally.

     

    So, that sure is a WTF, but the WTF is in ADO.

     

    Back to the WTF at hand. I suspect this is just test code put in before real data is available, and before that happened, the programmer moved on to other tasks and it was forgotten and never changed to the real values. Wrong, but something that happens to us all occasionally. He should have put a TODO-comment there...

  • (cs) in reply to Anonymous

    Anyone else think that a dinosaur is a little bit of an inappropriate logo for a forward thinking 'world class' consulting company?

    Oh, I get it, they're making a subtle reference to Oracle's relevance to the modern world........

  • (cs) in reply to pjabbott
    pjabbott:

    Am I the only one who looks at "&verify=1" and gets an ominous feeling?  I hope that's not a flag put in the URL query string to perform some sort of security or input verification, because if it is, the user could theoretically replace it with "&verify=0" to do an end run around the measures in place. 

    The query string will be visible by the user in their address bar since a response.redirect is being perfomed instead of a server.transfer.  Maybe I'm just paranoid.

     

    I get an ominous feeling too, because it should read "&amp;verify=1". It says so somewhere in the URL RFC. Luckily browsers will eat "&verify=1" as if it was correct.

    Drak

  • (cs) in reply to cm5400
    cm5400:

    Do programmers actually get paid by the line?  (cringe...Waits for flame thrower to hit)  I have never actually programmed outside of work before.  I can't see where that would be a good way to do business, on the other hand it could be very profitable...



    Ahh... Finally code generators are starting to pay off...

    I think this would also explain the great pyramids of DIV
     
  • (cs) in reply to wtijsma

    Actually, it would explain most of the WTF's here, they're not bad programmers, they're good consultants forced to write this type of code by their evil management.

  • (cs) in reply to Z
    Anonymous:
    As Edsger Dijkstra put it, one should not measure lines of code produced by a programmer, but lines of code spent.


    I get paid like that. That's why I don't use VB, because you can't put all code on 1 line.
  • (cs) in reply to wtijsma
    wtijsma:
    Actually, it would explain most of the WTF's here, they're not bad programmers, they're good consultants forced to write this type of code by their evil management.


    I most definitely beg to differ.  I've had to maintain code from very incompetent consultants.  Some of them may have been genuinely stupid, but most of them is just that they don't care enough to do things the Right Way, or to even learn beyond code that merely somehow works.

        -dZ.
  • (cs) in reply to wtijsma
    wtijsma:
    Anonymous:
    As Edsger Dijkstra put it, one should not measure lines of code produced by a programmer, but lines of code spent.


    I get paid like that. That's why I don't use VB, because you can't put all code on 1 line.


    I believe you can put it in one line.  I think you use colon ':' to separate the commands, just like you would use a semi-colon ';' in other languages.  Don't forget the "BASIC" in the "VisuaBasic" :)

        dZ.
  • (cs) in reply to DZ-Jay
    DZ-Jay:
    wtijsma:
    Actually, it would explain most of the WTF's here, they're not bad programmers, they're good consultants forced to write this type of code by their evil management.


    I most definitely beg to differ.  I've had to maintain code from very incompetent consultants.  Some of them may have been genuinely stupid, but most of them is just that they don't care enough to do things the Right Way, or to even learn beyond code that merely somehow works.

        -dZ.


    OOh, Don't get me started on the incompetent consultant bandwagon. Case in point:

    I used to work for a small company, and eventually received a better offer in the games industry, naturally, like an idiot, I took it. The company, trying to get the product I started to production hired a highly paid consultant. I got sick of the gaming world, and came back to the company I worked for. My code seemed to have morphed into some tangle of WTFs. The product was never released and the company tanked.

    Why? The consultant allowed his own arrogance seep into the code. Most of the stuff I had working, and working well was completely hosed. It took many months to get the program up and running again before the company finally went under.

  • (cs) in reply to DZ-Jay
    DZ-Jay:

    I believe you can put it in one line.  I think you use colon ':' to separate the commands, just like you would use a semi-colon ';' in other languages.  Don't forget the "BASIC" in the "VisuaBasic" :)


    You're right, I remember again... argh... it's all coming back to me... just thought I got rid of the VB bad trip flashbacks ;-)
  • Paul (unregistered) in reply to Drak

    Only if you're Response.Write(...)ing it.  If you're Response.Redirect(...)ing, then it should be & and not &amp;

    Try it and see.

  • (cs) in reply to wtijsma
    wtijsma:
    DZ-Jay:

    I believe you can put it in one line.  I think you use colon ':' to separate the commands, just like you would use a semi-colon ';' in other languages.  Don't forget the "BASIC" in the "VisuaBasic" :)


    You're right, I remember again... argh... it's all coming back to me... just thought I got rid of the VB bad trip flashbacks ;-)


    The sad thing is that ... er... I never got rid of them, and forever was cursed to retain that "knowledge". :(

        dZ.

Leave a comment on “Damned IF You Do, Damned ELSE You Don't”

Log In or post as a guest

Replying to comment #:

« Return to Article