| « Prev | Page 1 | Page 2 | Page 3 | Next » |
|
I believe it's real ... there is no way anyone could make this up.
|
|
I swear I worked with a guy that wrote code like this.
|
|
SQL Server 2000: $1850
Visual Studio 6: $750 1 Year MSDN Universal: $3500 Writing this line of "code:" ReturnStatus = "sqlConnection" & CStr(connectionNum) & ".Close()"Priceless. |
i'm still working with one of those :) Mike R, rotfl :D |
Re: Drowning in the Connection Pool
2005-06-06 13:39
•
by
Anonymous
|
Who knows maybe you two are colleagues! |
Re: Drowning in the Connection Pool
2005-06-06 13:44
•
by
christoofar
|
|
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. |
Re: Drowning in the Connection Pool
2005-06-06 13:44
•
by
CrankyPants
|
|
On Error Resume Next -- Helping bad VB progammers ignore their errors for 12 years. I'm surprised it even compiled! Is there no type checking in that compiler? |
|
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) |
Re: Drowning in the Connection Pool
2005-06-06 13:53
•
by
spaceCode
|
|
OMG ME TOO!
hahah |
Re: Drowning in the Connection Pool
2005-06-06 13:53
•
by
christoofar
|
|
Visual Basic programmers who use On Error Resume Next on everything are also found to have high incidents of:
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 |
Re: Drowning in the Connection Pool
2005-06-06 13:56
•
by
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 |
Re: Drowning in the Connection Pool
2005-06-06 13:57
•
by
PstScrpt
|
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. |
Exit function, exit function, exit function.... |
Re: Drowning in the Connection Pool
2005-06-06 13:59
•
by
christoofar
|
|
OMG nevermind, this is VB.NET code.... oy vey brand new language, and now brand new WTFs to be generated every day.
|
Re: Drowning in the Connection Pool
2005-06-06 14:01
•
by
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? ?!?!?!!? |
Re: Drowning in the Connection Pool
2005-06-06 14:01
•
by
PstScrpt
|
VB.Net has "On Error..."? I thought it was supposed to use try/catch/finally. |
|
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.... |
|
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? |
Re: Drowning in the Connection Pool
2005-06-06 14:25
•
by
JamesCurran
|
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....) |
Re: Drowning in the Connection Pool
2005-06-06 14:30
•
by
Richard
|
|
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. :-)
|
Re: Drowning in the Connection Pool
2005-06-06 14:42
•
by
fregas
|
|
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... |
Because you never can be too sure the function will exit. |
Re: Drowning in the Connection Pool
2005-06-06 15:07
•
by
Matt B
|
yay for backwards compatibility!! |
|
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... |
Re: Drowning in the Connection Pool
2005-06-06 15:10
•
by
rogthefrog
|
Examples like this should be on a different site named thedailyOMG.com. Stunning. |
Re: Drowning in the Connection Pool
2005-06-06 15:18
•
by
Im|tal
|
excellent! * |
Re: Drowning in the Connection Pool
2005-06-06 15:26
•
by
loneprogrammer
|
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! |
|
I love this... Return True ' Return a true value. What happens if the End Function doesn't work? Shouldn't there be a fourth layer of redundancy in this method?
|
Re: Drowning in the Connection Pool
2005-06-06 15:32
•
by
PstScrpt
|
Just to be picky, "End Function" isn't an executable statement. It's like a closing curly bracket in C or Java. |
|
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. |
Re: Drowning in the Connection Pool
2005-06-06 15:57
•
by
rogthefrog
|
|
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.
|
Re: Drowning in the Connection Pool
2005-06-06 16:16
•
by
strongarm
|
Thanks for the reminder, I tried purging all VB knowledge a few years back, it appears I was more successful than I thought.
|
|
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. |
Aw, c'mon, Richard. Name it! How about the initials? At that price and code quality, they should be out of business soon. |
|
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 |
Re: Drowning in the Connection Pool
2005-06-06 17:01
•
by
DjDanny
|
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?! |
Re: Drowning in the Connection Pool
2005-06-06 17:08
•
by
uber1024
|
|
And he's only 1 line away from having code that does something useful, too.
|
|
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. |
|
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 ... |
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: Also remember that those 'try()'s expand into full Try/Catch
Now isn't that a hell of a lot easier? Yes. Any problems caused? Not
It's not how you should do everything, but it has very valid
|
|
Just one little change to the project would have prevented this from compiling - turn Strict On. No VB.NET project should be without it!! [;)]
|
Re: I think I should update all of my code
2005-06-06 18:29
•
by
mizhi
|
It's like C code I run into where the return type of the function is void. void foo() { . . miles of bad code . return; } |
|
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.
|
|
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.
|
Re: Drowning in the Connection Pool
2005-06-06 19:08
•
by
A Wizard A True Star
|
|
Meant to say "Eval", not "Exec".
|
Re: Drowning in the Connection Pool
2005-06-06 19:39
•
by
Rank Amateur
|
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 |
WTF??? If I saw the above C code I would assume the programmer is a stupid VB coder. Lets analyse your example.
|
Re: Drowning in the Connection Pool
2005-06-06 20:56
•
by
Jon Limjap
|
It's not VB.NET, mind you. It's Visual Basic 6. |
Re: Drowning in the Connection Pool
2005-06-06 21:01
•
by
Alex Papadimoulis
|
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. |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |