• the raven (unregistered)

    I believe it's real ... there is no way anyone could make this up.

  • (cs)

    I swear I worked with a guy that wrote code like this.

  • (cs)

    SQL Server 2000: $1850
    Visual Studio 6: $750
    1 Year MSDN Universal: $3500

    Writing this line of "code:"

    ReturnStatus = "sqlConnection" & CStr(connectionNum) & ".Close()"
    Priceless.

  • (cs) in reply to Sean
    Sean:
    I swear I worked with a guy that wrote code like this.

    i'm still working with one of those :)

    Mike R, rotfl :D
  • Anonymous (unregistered) in reply to short

    short:
    Sean:
    I swear I worked with a guy that wrote code like this.

    i'm still working with one of those :)

    Mike R, rotfl :D

    Who knows maybe you two are colleagues!

  • (cs) in reply to Anonymous

    I think people who have been found to be writing this type of code should be blackballed from I/T, it (and consulting) give I/T workers a bad reputation.

    Ugh, I need a Percoset after looking at that.

  • CrankyPants (unregistered) in reply to short

    <FONT face="Courier New">On Error Resume Next</FONT> -- Helping bad VB progammers ignore their errors for 12 years.

    I'm surprised it even compiled!  Is there no type checking in that compiler?

  • Majromax (unregistered)

    Okay... there's only one possible way that someone exhibiting such utter stupidity can continue to breathe: he's used to scripting languages.  In fact, he's so used to them, that his default state is:

    state = 'breathe()'
    exec(state)

  • spaceCode (unregistered) in reply to short

    OMG ME TOO!

    hahah


  • (cs) in reply to CrankyPants

    Visual Basic programmers who use On Error Resume Next on everything are also found to have high incidents of:

    • Denial
    • Self-loathing
    • Keeping painful secrets from their loved ones
    • Fear of conflict (for being screamed at because some troll user saw a computer error)
    Are you a Visual Basic programmer?  Are you experiencing any of these symptoms?  Please call.  Don't hesitate, the future of  your business software is at stake.

    1-800-GET-HELP
  • (cs) in reply to christoofar

    Public Function CloseConnection(ByVal connectionNum As Integer) As Integer
      On Error Resume Next
      Dim ReturnStatus As Integer
      ReturnStatus = "sqlConnection" & CStr(connectionNum) & ".Close()"

      If ReturnStatus <> 0 Then
        Return False  <----- WHAT THE FUCK THIS WONT EVEN COMPILE RETURN ISN'T A KEYWORD!!!!!
      End If

      Return True
      Exit Function
    End Function

  • (cs) in reply to CrankyPants
    Anonymous:

    <FONT face="Courier New">On Error Resume Next</FONT> -- Helping bad VB progammers ignore their errors for 12 years.

    I'm surprised it even compiled!  Is there no type checking in that compiler?

    No, since version 4, VB has freely converted between integers and strings.  This is alternately referred to as "Implicit Type Conversion" and "Evil Type Conversion".  I take advantage of the shortcut, since I figure I've lost type safety, anyway. 

    The string from the original post will always evaluate to 0.  Even if the "On Error" wasn't there, this function would always return success.

  • (cs)
    Alex Papadimoulis:

      Return True
      Exit Function
    End Function

    Exit function, exit function, exit function....

  • (cs) in reply to christoofar

    OMG nevermind, this is VB.NET code.... oy vey brand new language, and now brand new WTFs to be generated every day.

  • (cs) in reply to christoofar

    Now... how in the hell in VB.NET (assuming that since RETURN is only a keyword in VB.NET).... can you possibly execute that sh** and expect it to hit a method?   ?!?!?!!?

  • (cs) in reply to christoofar

    christoofar:
    OMG nevermind, this is VB.NET code.... oy vey brand new language, and now brand new WTFs to be generated every day.

    VB.Net has "On Error..."?  I thought it was supposed to use try/catch/finally.

  • (cs)

    OMG nevermind this thing will never be able to execute anyway, starting at the first line of executable code.  Look at what the type of "ReturnStatus" is....

  • lw (unregistered)

    Ya know, this doesn't look so much like a coding error to me, but the result of an automated merge that no one checked.  I'll bet half a Coke that there was a line executing the string at some point, and the merge mangled it.   ClearCase, anyone?

  • (cs) in reply to Majromax

    Anonymous:
    Okay... there's only one possible way that someone exhibiting such utter stupidity can continue to breathe: he's used to scripting languages. 

    Further, I'd bet he came from a dBase -like language, where stuff like that actually worked!   (Since FoxPro is one such language, I wonder if that code would work there....)

  • Richard (unregistered) in reply to Majromax

    Those two lines in particular remind of an application that was written with exactly that kind of code all the way through it, costing near to $1k. Can't name it unfortunately because the author might (though probably not) be reading this. :-)

     

  • fregas (unregistered) in reply to the raven

    At last.

    At last we are bequeathed a WTF that harkens back to the days of old, when the glory of WTF was at its prime.  When code so putrid, so insepid, so utterly devoid of anything resembling logic, experience or basic programming rears its ugly head, causing us to shout in ardent disbelief: "WHAT THE FUCK!????"

    And of course, its in Visual Basic...

  • (cs)


    Exit Function
    End Function
    Because you never can be too sure the function will exit.

  • (cs) in reply to PstScrpt
    PstScrpt:

    VB.Net has "On Error..."?  I thought it was supposed to use try/catch/finally.




    yay for backwards compatibility!!  
  • (cs)

    So many things wrong with this small piece of code ... I can't even imagine what the rest is like...

     head hurts ... must lie down...

  • (cs) in reply to the raven

    Anonymous:
    I believe it's real ... there is no way anyone could make this up.

    Examples like this should be on a different site named thedailyOMG.com. Stunning.

  • Im|tal (unregistered) in reply to Anonymous
    Anonymous:

    short:
    Sean:
    I swear I worked with a guy that wrote code like this.

    i'm still working with one of those :)

    Mike R, rotfl :D

    Who knows maybe you two are colleagues!



    excellent! *
  • (cs) in reply to lw
    Anonymous:
    Ya know, this doesn't look so much like a coding error to me, but the result of an automated merge that no one checked.

    If no one checked it, why is it in the program?  You can't just put junk in your code and expect the computer to know what you mean!

  • (cs)

    I love this...

      Return True      ' Return a true value.
      Exit Function    ' But just in case that didn't work exit the function.
    End Function       ' No, I really really mean it...

    <FONT color=#000000>What happens if the End Function doesn't work? Shouldn't there be a fourth layer of redundancy in this method?</FONT>

     

  • (cs) in reply to strongarm
    strongarm:

    I love this...

      Return True      ' Return a true value.
      Exit Function    ' But just in case that didn't work exit the function.
    End Function       ' No, I really really mean it...

    <FONT color=#000000>What happens if the End Function doesn't work? Shouldn't there be a fourth layer of redundancy in this method?</FONT>

     

    Just to be picky, "End Function" isn't an executable statement.  It's like a closing curly bracket in C or Java.

  • Richard Dudley (unregistered)

    It's not bad enough that this is returning booleans as integers.  Then again, we couldn't expect Option Strict to be set to On.

    If I ever needed an excuse to switch to C#, I now have one--to avoid being grouped with this example.

  • (cs) in reply to Richard Dudley

    In the car this morning I was wondering if VB had singlehandedly provided the world with the biggest number of WTFs, both in absolute terms and relatively to, say, the installed code base. This site seems to confirm my fear.

  • (cs) in reply to PstScrpt
    PstScrpt:
    strongarm:

    I love this...

      Return True      ' Return a true value.
      Exit Function    ' But just in case that didn't work exit the function.
    End Function       ' No, I really really mean it...

    <FONT color=#000000>What happens if the End Function doesn't work? Shouldn't there be a fourth layer of redundancy in this method?</FONT>

     

    Just to be picky, "End Function" isn't an executable statement.  It's like a closing curly bracket in C or Java.

    Thanks for the reminder, I tried purging all VB knowledge a few years back, it appears I was more successful than I thought.

     

  • (cs)

    Most languages just give you enough rope to hang yourself.

    VB without Option Strict allows you to implicitly convert everyday household objects into EVEN MORE rope.

  • (cs) in reply to Richard
    Anonymous:

    ...Can't name it unfortunately because the author might (though probably not) be reading this. :-)


    Aw, c'mon, Richard. Name it! How about the initials? At that price and code quality, they should be out of business soon.
  • (cs)
    1. Read post
    2. Take off glasses
    3. Clean glasses
    4. Put glasses back on
    5. Re-Read post
    6. Resist urge to through myself in CNC in next building
  • DjDanny (unregistered) in reply to PstScrpt
    PstScrpt:

    christoofar:
    OMG nevermind, this is VB.NET code.... oy vey brand new language, and now brand new WTFs to be generated every day.

    VB.Net has "On Error..."?  I thought it was supposed to use try/catch/finally.

     

    oh yes, it does have try/catch/finally, but you can't expect VB 'programmers' to give up their most useful command. Why write decent code, when you can just pretend it works fine all the time?!

  • (cs) in reply to the raven

    And he's only 1 line away from having code that does something useful, too.

  • (cs)

    If only he were using vbscript instead of vb.net he'd have been oh so very close.
    Just adding

    Execute(ReturnStatus)

    in the empty line would have done the job. Ah what a pity.


    Actually, I wonder if it's possible that this could have been migrated over from a vbscript, and the line above removed by a dimwitted programmer in order to get it to compile without complaining. Worth a thought.

  • (cs)

    I almost missed the best part -- look at the argument of the function.  At first I thought he was passing in a reference to a connection object ... but, nope .... it's an integer -- the "connection number" !  The index to a global array of connection objects, you might think?  That would be bad enough, but again, no ... apparently he has the global variables "sqlConnection1", "sqlConnection2", etc all declared and opened in his application !  

    And of course, since this code actually does NOTHING, and none of these ever get closed, that makes it all even worse. 

    A true classic.

    I'd love to see more of this code ... it's amazing how there's not even a shred of understanding about the most basic of programming concepts present in this code ...

  • (cs) in reply to DjDanny
    Anonymous:
    PstScrpt:

    christoofar:
    OMG nevermind, this is VB.NET code.... oy vey brand new language, and now brand new WTFs to be generated every day.

    VB.Net has "On Error..."?  I thought it was supposed to use try/catch/finally.

     

    oh yes, it does have try/catch/finally, but you can't expect VB 'programmers' to give up their most useful command. Why write decent code, when you can just pretend it works fine all the time?!


    Why do so many people have a problem with a tool which admittedly can be abused, but not half as much as dozens of things in C++ and other languages?

    Let's look at an example - log all the attributes of a bunch of files in a directory as you try to move them elsewhere.

    Try/Catch scenario psuedocode:
    try (get list of files)
    try (loop through files)
        try (log some file attributes)
        try (log some more attributes)
        try (log permissions)
        try (copy file)
        try (delete file)
    end loop

    Also remember that those 'try()'s expand into full Try/Catch structures where essentially all you do is discard the error and carry on.  Surely there's a better and quicker way to do that with the same result?

    Resume next scenario pseudocode:
    on error resume next
    get list of files
    loop through files
        log all details
        copy file
        delete file
    end loop

    Now isn't that a hell of a lot easier? Yes. Any problems caused? Not really, since we were discarding errors anyway. Before anyone moans that I'm making more work in the Try/Catch case, remember how granular NTFS permissions are. You may very well have permissions to some file info but not something else. Resume next means not having to read and discard errors for things like that.

    It's not how you should do everything, but it has very valid reasons, the above being just one and probably not one of the best examples, either. Now, let's have less stupidity from elitist morons.

  • Ken (unregistered)

    Just one little change to the project would have prevented this from compiling - turn Strict On.  No VB.NET project should be without it!!  [;)]

  • (cs) in reply to smitty_one_each
    smitty_one_each:

    Exit Function
    End Function
    Because you never can be too sure the function will exit.


    It's like C code I run into where the return type of the function is void.

    void foo()
    {
    .
    . miles of bad code
    .
    return;
    }

  • (cs)

    Way, way back in the day (circa 1979), on a DEC RSTS/E OS, returning a string to execute a system dispatch Was The Way Things Were Done, like:

    A$=SYS(CHR$(13)+...)

    IF A$="" THEN PRINT "SYSTEM CALL ERROR" ELSE...

    Yes, RSTS used BASIC for system utilities.  Doubt that the author of the original code knew that, but it explains more about VB than I wanted to know:  Microsoft's original business was writing BASIC interpreters using DEC hardware to cross-compile.

     

  • (cs)

    I'm pretty sure this is just code migrated from ASP to ASP.NET. There was probably a call to Exec() around the string. When they tried to compile it in .NET they saw the error "Name 'Exec' is not declared" and took out the Exec. Voila, it compiles!

    Of course, it should have occurred to whoever took out the Exec that this function was no longer doing anything. Still, the variable naming is an even bigger WTF. Somewhere in that app, there's a set of global variables declared like:

    Dim sqlConnection1

    Dim sqlConnection2

    Dim sqlConnection3

    Dim sqlConnection4

    Dim sqlConnection5

    Dim sqlConnection6

    ...

    Dim sqlConnection255

    ...

    Yeah. We really need to see some more of this code.

     

  • (cs) in reply to A Wizard A True Star

    Meant to say "Eval", not "Exec".

     

  • (cs) in reply to A Wizard A True Star
    A Wizard A True Star:

    I'm pretty sure this is just code migrated from ASP to ASP.NET. There was probably a call to Exec() around the string. When they tried to compile it in .NET they saw the error "Name 'Exec' is not declared" and took out the Exec. Voila, it compiles!

    <Snip>

    Plausible scenario, like the earlier theory that it came from VBScript, but what about the fact that ReturnStatus is declared as integer? Either in porting they changed it from string (WTF!), or it never worked in ASP to start with (WTF^2!). Right?

    --RA

  • Riken (unregistered) in reply to RayS
    RayS:
    Let's look at an example - log all the attributes of a bunch of files in a directory as you try to move them elsewhere.

    Try/Catch scenario psuedocode:
    try (get list of files)
    try (loop through files)
        try (log some file attributes)
        try (log some more attributes)
        try (log permissions)
        try (copy file)
        try (delete file)
    end loop

    Also remember that those 'try()'s expand into full Try/Catch structures where essentially all you do is discard the error and carry on.

    It's not how you should do everything, but it has very valid reasons, the above being just one and probably not one of the best examples, either. Now, let's have less stupidity from elitist morons.

    WTF??? If I saw the above C code I would assume the programmer is a stupid VB coder.

    Lets analyse your example.

    try (get list of files) --- if this fails, we shouldn't loop
    try (loop through files) --- why would this fail? oh yes because we didn't check the error on the previous line
        try (log stuff) --- Hmmm, logging didn't work, we'll ignore it
        try (copy file) --- Hmmm, copy didn't work, we'll ignore it
        try (delete file) --- But the delete did work, so now we have no log, no copy, no original and no explanation
    end loop

    Gee you're right, bad programmers can write bad code in any language.

  • (cs)

    vomit

  • (cs) in reply to christoofar
    christoofar:
    OMG nevermind, this is VB.NET code.... oy vey brand new language, and now brand new WTFs to be generated every day.


    It's not VB.NET, mind you. It's Visual Basic 6.
  • (cs) in reply to Jon Limjap

    Jon Limjap:
    christoofar:
    OMG nevermind, this is VB.NET code.... oy vey brand new language, and now brand new WTFs to be generated every day.


    It's not VB.NET, mind you. It's Visual Basic 6.

    Sadly .. it actually is VB.NET ... I have another example from this project I'll be posting sometime later. One tell-tale sign is the use of the Return keyword. VB6 does not support it.

Leave a comment on “Drowning in the Connection Pool”

Log In or post as a guest

Replying to comment #:

« Return to Article