|
How can this run without an error?? Or: Why 'On Error Resume Next' + Poor Programmer = WTF
Last post 03-21-2008 10:06 AM by Lysis. 12 replies.
-
03-20-2008 2:01 PM
|
|
-
ObiWayneKenobi


- Joined on 03-23-2007
- Posts 142
|
How can this run without an error?? Or: Why 'On Error Resume Next' + Poor Programmer = WTF
More reason why, while VBScript is NOT the real WTF, most programmers who "program" (and I use that term loosely) in it are. Found this from the guy I replaced (indentation and spacing, or lack thereof, is left as-is): if pIdCustomer=0 then pPriceColumn="retail" else mySQL="select priceColumn from customers where idCustomer='" & pIdCustomer & "'" call getFromDatabase(mySQL, rsTemp, "ViewItem_1") pPriceColumn=rstemp("pricecolumn") end if if pIdCustomerType=4 or pIdCustomerType=5 or pIdCustomer=17873 or pIdCustomer=21385 then mySQL="Select accessLevel,groupId from customers where idcustomer="&pidCustomer call getfromDatabase(mySQL, rstemp, "comersus_customerUtilitiesMenu.asp") end if if not rstemp.eof then paccessLevel=rsTemp("accessLevel") pIdGroup=rsTemp("groupId") else paccessLevel=1 pIdGroup=0 end if
Basically to sum it up: The way this is written, without On Error Resume Next (which every page has) it will fail if the type/id check doesn't get called, because "rstemp" (what a descriptive name, eh?) would only have the value of the prior query checking for the priceColumn, and wouldn't have any columns called "accessLevel" or "groupId". Not to mention that it's not using Option Explicit, so any variable declared inside the If block is automatically what amounts to global level and visible to everything. *sigh* It's days like this I hate being a programmer. EDIT: And, just for bonus WTFery, here's some javascript from the same page (The real WTF is the naming): <!-- function smt(){ //alert("fired") document.getElementById("frm").submit(); } function rpt(){ //alert("fired") document.getElementById("frm2").submit(); } function namrpt(){ //alert("fired") document.getElementById("frm3").submit(); } //-->
The Daily WTF Forums. You will never find a more wretched hive of scum and villainy.
|
|
-
-
Lysis


- Joined on 09-13-2007
- Posts 236
|
Re: How can this run without an error?? Or: Why 'On Error Resume Next' + Poor Programmer = WTF
ObiWayneKenobi:More reason why, while VBScript is NOT the real WTF, most programmers who "program" (and I use that term loosely) in it are. Found this from the guy I replaced (indentation and spacing, or lack thereof, is left as-is): if pIdCustomer=0 then pPriceColumn="retail" else mySQL="select priceColumn from customers where idCustomer='" & pIdCustomer & "'" call getFromDatabase(mySQL, rsTemp, "ViewItem_1") pPriceColumn=rstemp("pricecolumn") end if if pIdCustomerType=4 or pIdCustomerType=5 or pIdCustomer=17873 or pIdCustomer=21385 then mySQL="Select accessLevel,groupId from customers where idcustomer="&pidCustomer call getfromDatabase(mySQL, rstemp, "comersus_customerUtilitiesMenu.asp") end if if not rstemp.eof then paccessLevel=rsTemp("accessLevel") pIdGroup=rsTemp("groupId") else paccessLevel=1 pIdGroup=0 end if
Basically to sum it up: The way this is written, without On Error Resume Next (which every page has) it will fail if the type/id check doesn't get called, because "rstemp" (what a descriptive name, eh?) would only have the value of the prior query checking for the priceColumn, and wouldn't have any columns called "accessLevel" or "groupId". Not to mention that it's not using Option Explicit, so any variable declared inside the If block is automatically what amounts to global level and visible to everything. *sigh* It's days like this I hate being a programmer. EDIT: And, just for bonus WTFery, here's some javascript from the same page (The real WTF is the naming): <!-- function smt(){ //alert("fired") document.getElementById("frm").submit(); } function rpt(){ //alert("fired") document.getElementById("frm2").submit(); } function namrpt(){ //alert("fired") document.getElementById("frm3").submit(); } //--> On Error Resume Next is cruise control to cooooooool.... Oh yeah, I copied/pasted the OP. I thought I'd give MasterAsshat something to do.
http://www.thebestpageintheuniverse.com
|
|
-
-
arty


- Joined on 01-09-2007
- Posts 105
|
Re: How can this run without an error?? Or: Why 'On Error Resume Next' + Poor Programmer = WTF
Lysis://alert("fired") Perhaps this is how he keeps from getting fired, despite this WTF?
|
|
-
-
morbiuswilters


- Joined on 01-15-2008
- East Coast Represent!
- Posts 2,978
|
Re: How can this run without an error?? Or: Why 'On Error Resume Next' + Poor Programmer = WTF
Good god, I think I've worked with whoever developed this before! I dunno, the variable names are a bit too descriptive, though...
< pstorer> Bans don't mean shit on the forum. It's like being on the Sex Offender List. You can still entice kids into your van with candy.
Want more? Go the IRC channel #TDWTFMafia on irc.slashnet.org.
Farmer Brown is MasterPlanSoftware. He created a new forum account because he is obsessed with me after I scorned him. Ignoring his trolling is the best way to deal with the crybaby.
|
|
-
-
TheRider


- Joined on 03-01-2005
- Zurich, Switzerland
- Posts 195
|
Re: How can this run without an error?? Or: Why 'On Error Resume Next' + Poor Programmer = WTF
Lysis:Oh yeah, I copied/pasted the OP. I thought I'd give MasterAsshat something to do.
You are pulling on everybody's nerves here, just to get at MasterPlanSoftware? What a moron you are. I pity you.
"correcting wrongs on the internet is like subtracting 1 from infinity"
|
|
-
-
Spectre


- Joined on 05-09-2007
- Posts 455
|
Re: How can this run without an error?? Or: Why 'On Error Resume Next' + Poor Programmer = WTF
The Real WTF is the indentation and the proper use of capital letters, or rather lack of them.
W00t, my tag made it to the front page, so the rebalancing is complete. Although, somehow, the cloud doesn't look more balanced than it was. Anyway, one last time,..
╩юфют√ь ёЄЁрэшЎрь яюЁр эр яхэёш■.
Visit #TDWTF @ SlashNET - the semi-official WTF IRC channel.
|
|
-
-
Arenzael


- Joined on 01-16-2008
- Posts 59
|
Re: How can this run without an error?? Or: Why 'On Error Resume Next' + Poor Programmer = WTF
I love it when people name their recordsets "rs". But, alas, what if I use more than one in a page? Ah, solution! Set rs = CreateObject("ADODB.RecordSet") Set rs1 = CreateObject("ADODB.RecordSet") Set rs2 = CreateObject("ADODB.RecordSet") That's right, it's even zero-based. And don't forget to set up 3 different sql variables for those recordsets so each query is kept separate. What's with the close method? Why would I need that, doesn't the ASP clean up its own garbage at the end of the page? The server only processes one page at a time, right?
<xml> <enterprisey>Yes</enterprisey> <synergistic>Very</synergistic> <collaberative>You Betcha</collaberative> <useful>Nope</useful> <performance>Not Much</performance> <efficiencies_gained>None</efficiencies_gained> <development_time>Eternity</development_time> </xml>
|
|
-
-
morbiuswilters


- Joined on 01-15-2008
- East Coast Represent!
- Posts 2,978
|
Re: How can this run without an error?? Or: Why 'On Error Resume Next' + Poor Programmer = WTF
Arenzael:I love it when people name their recordsets "rs". But, alas, what if I use more than one in a page? Ah, solution! Set rs = CreateObject("ADODB.RecordSet") Set rs1 = CreateObject("ADODB.RecordSet") Set rs2 = CreateObject("ADODB.RecordSet") That's right, it's even zero-based. And don't forget to set up 3 different sql variables for those recordsets so each query is kept separate. What's with the close method? Why would I need that, doesn't the ASP clean up its own garbage at the end of the page? The server only processes one page at a time, right?
My quote above actually referred to this very practice. I worked with a developer who (I guess) learned VB before he learned PHP. His PHP code all looked like: $r = mysql_query('select id from '.$_GET['tbl'].' where name=\''.$_GET['name'].'\'', $DB)); while ($oRS = mysql_fetch_object($r)) { $oRS1 = mysql_fetch_object(mysql_query('select foo from '.$_GET['tbl'].' where id='.$oRS->id, $DB)); echo('<table><tr><td>'.$oRS1->foo.'</td></tr></table>'); }
If that looks illegible to you because you don't know PHP, don't worry, it actually is! And yes, this developer passed table names as GET vars. And yes, he did not know about query escaping. And yes, he would actually select out ids from a table and then select out individual fields in a loop -- sometimes the loops were several levels deep, resulting in 14,000+ queries on a page! And yes, he used tables with one row and one column instead of divs because "divs are rendered too slow". Oh, and this guy really had a problem with people of Irish descent because their names always seemed to break his "perfect code". He actually told me once "those PHP guys need to do something about these Irish people because they keep breaking our applications!" I guess he figured genocide was the only option...
< pstorer> Bans don't mean shit on the forum. It's like being on the Sex Offender List. You can still entice kids into your van with candy.
Want more? Go the IRC channel #TDWTFMafia on irc.slashnet.org.
Farmer Brown is MasterPlanSoftware. He created a new forum account because he is obsessed with me after I scorned him. Ignoring his trolling is the best way to deal with the crybaby.
|
|
-
-
medialint


- Joined on 12-17-2007
- San Francisco
- Posts 342
|
Re: How can this run without an error?? Or: Why 'On Error Resume Next' + Poor Programmer = WTF
Being pretty knowledgeable of VBariants I'm on VB boards a lot (especially devshed where I moderate VB) I can't tell you how many times someone has posted a code snippet with the infamous "doesn't work" error. After going around in circles for a while someone usually says: "I can't believe you aren't getting an error" Then the OP posts more of the code Then we see ... On Error Resume Next If the OP had simply been willing to listen to the error messages VB throws out usually they'd find the obvious. I suggest that all instances of On Error Resume Next be replaced with On Error Shoot Developer In The Head Fools like this make us all look bad and help prop up the "VB is a script kiddie toy" image when, actually, it is rather useful for some things so long as idiots like this don't get near it.
There are three kinds of people: those who make things happen, those who watch things happen and those who wonder what happened.
|
|
-
-
ObiWayneKenobi


- Joined on 03-23-2007
- Posts 142
|
Re: How can this run without an error?? Or: Why 'On Error Resume Next' + Poor Programmer = WTF
I'm inclinded to agree - this guy seems to have either picked up a "Teach Yourself VBScript In 10 Minutes", or deliberately obfuscated his code for job security. The whole fucking codebase is loaded with shit like this. Loops within loops within three levels of if statements that do the exact same loop with a couple of lines changed, alternate between outputting all HTML in Response.Write and using the <%= %> tags, barely any indentation, variable names that read like heiroglyphics. Perhaps the biggest WTF of all is that there are several thousand pages of this stuff. So even if I were to find the time to refactor them here and there to not be spaghetti, it would take me about 10 years to refactor all of it... assuming that I could refactor one page per day.
The Daily WTF Forums. You will never find a more wretched hive of scum and villainy.
|
|
-
-
-
Daid


- Joined on 01-30-2007
- Posts 282
|
Re: How can this run without an error?? Or: Why 'On Error Resume Next' + Poor Programmer = WTF
JonAxtell:
I always use it on my resize event handlers...
and the correct search is: http://www.google.com/codesearch?hl=en&lr=&q=%22On+Error+Resume+Next%22&btnG=Search
|
|
-
-
Lysis


- Joined on 09-13-2007
- Posts 236
|
Re: How can this run without an error?? Or: Why 'On Error Resume Next' + Poor Programmer = WTF
TheRider: Lysis:Oh yeah, I copied/pasted the OP. I thought I'd give MasterAsshat something to do.
You are pulling on everybody's nerves here, just to get at MasterPlanSoftware? What a moron you are. I pity you. QQ
http://www.thebestpageintheuniverse.com
|
|
Page 1 of 1 (13 items)
|
|
|