- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
oh VB, when will they ever learn
Admin
Line numbers? Are they mad? Surely labels are the way forward?
Admin
This was obviously ported from Apple 2 BASIC. Not a wtf.
Admin
That said, TRWTF is VBA.
Admin
Obviously with "Let i =" in there!
Admin
Admin
Admin
And that makes it better how?
The only GOTOs that should be used are in very low level code - I mean C, Assembler, and those benighted languages that were designed for punch cards and coding sheets.
Admin
Sometimes people just work far too bloody hard.
Admin
The slightly-less WTF version. Might not need that * True, not sure, haven't done BASIC in a while.
Admin
How about using goto within an if statement in place of just putting the code there?
If you think VBA is TRWTF, wait until they roll out C#A.
Addendum (2010-11-24 12:17): Doh! Disregard that.
Admin
One goto that I'm fine with is in a switch statement in C#, like this: http://www.cookcomputing.com/blog/archives/000385.html. This is safer than fall-through switch statements, I dare say.
Anywhom, it looks like time to refactor, eh?
Admin
Yes, yes there is.
Admin
We did some pretty complex things in VBA (Excel and Visio) that we are proud of. Of course, we only do VBA when it produces the best solution for the end user, unlike some people that do VBA because they fail at real languages like Java or Ruby and their corresponding architectures.
Admin
From: user To: support<The [email protected]> Subject: Bug in CMCalc Description: One of my option buttons has dissappeared, and I get a warning pop-up that says "FILE_NOT_FOUND".
Admin
Still, if it's at all representative of the rest of the application (as the submitter implies it is), then you can bet there are probably larger modules using much more complex if-goto-else-goto spaghetti logic.
Well, I do suppose we can agree on that.Admin
Obviously being paid by the number of lines of code.
Admin
Admin
FTFY.
Admin
Yeah, this is a fail. Trash goto statements all you want. I don't like them either.
However, those aren't line numbers... those are labels.
Face palm.
Admin
"they fail at real languages like Java or Ruby"
Real languages? Don't listen, folks! Java and Ruby are just a fad! VB/VBA is still rockin' the kingdom!
Admin
And most programming languages will support my calling functions adasdadasd() and func1002(). It doesn't make it a good idea.
Admin
What is it? The only real issue with GOTO is that, if you use it incorrectly, it can result in some screwy logic (e.g 10 goto 20 goto 50 goto 40 goto 10) making the code error prone and hard to maintain.
In this case it's perfectly linear, and reasonably clear. I certainly wouldn't complain if I saw it, though I'd probably think it was a little weird.
Admin
I still haven't found a language that supports the next big thing in flow control: WENTTO.
As in, if WENTTO 100 then GOTO 300.
Simple and easy to understand, just as best practices dictate.
Admin
I work a lot with legacy code, and the sample shown is actually pretty good for code over 10 years old.
So, I tried to find where the WTF was in the article, and found it:
The problem is the developers maintaining the application that mostly know nothing, including the submitter, "Will".
Admin
It was a joke, but since a couple of you insist on being smart arses, from MSDN:
In case you missed it, the syntax does indeed differ.
Admin
Oh wow! That's the sort of logic I wrote for BASIC on the BBC Master, back when I was about 8. There wasn't any ELSE or WHILE, or... pretty much anything really. I still thought it was fantastic, though.
Ah, the nostalgia.
Admin
Admin
Clearly, someone found out what the B in VB stands for and was being a smartass about it.
Admin
Clean an understandable? I think I need eye bleach after seeing that...
Just because a language supports a certain construct, does not mean that you should use it especially if there is nothing to gain. In fact you loose readability and make it brittle because somewhere else there may be a line of code pointing to that GOTO (which for whatever reason you removed), but you'd never know until a runtime error is thrown.
Admin
As for today's WTF, sometimes all you can do is sigh. Unless you work with these people, in which case "Horrific Workplace Shooting" should be dominating the headlines tomorrow.
Admin
I was going to post your current score but I lost count.
Anyway, modo wins.
Admin
Admin
Since VBA line numbers are optional and can be used out of sequence, they are really nothing more than numeric labels, despite the name used in the MSDN documentation.
Admin
groin kick
That was NOT funny. I believe that you were aiming for 'funny' but all I got was feeling similar to chewing tinfoil and nails against a black board.
Admin
I know we're all adults here, but if anyone doesn't "get it" yet why gotos are bad, here's one reason:
10 ...dostuff... goto 100
40 ...otherstuff... goto 100
...blah... 100 ...more...
Now... since we all know code expands to fill the available space (which is, for all practical purposes, infinite), this will eventually get too complicated to fit on one screen, or, perhaps, even into one brain. Then, as you're debugging the "...more..." stuff after 100, the question inevitably arises: how did I get here? Was it from "dostuff" or "otherstuff"?
This is why every language with "goto" also needs "camefrom". As in:
if camefrom = 40 then ... and so on...
Admin
Yep, my first foray into programming was BBC BASIC.
I don't care what they compile to nor how the language uses them, there are two different constructs here, you were inaccurate.
Admin
dwb_eng() is a very clear mnemonic. It refers to the author, a DWeeB_ENGineer.
Admin
Admin
Although, the code works, and that's all that really matters. I certainly would complain if I saw it, but I'd probably just leave it alone (though I'd certainly be inclined to send a copy to this site, as the submitter did).
Admin
I've been coding in VBA since Office for Windows 95 came out and, while I'm sure I have written my share of WTF, I have never written anything that stupid. I wonder if the original coder thought he was being funny.
Admin
Admin
Admin
I saw this too, but had to reply anyway because some "developer" will see those comments and think that this is the correct way of doing things... And with my luck, I'll have to maintain their steaming pile of GOTOs. :(
Admin
I think you just highlighted the fact that I've never really developed in VBA, or used labels, but the original point stands... Just because it supports the construct, doesn't mean you should use it as it turns the code from ugly, to evil (IMO).
Admin
Admin
Admin
Admin
Fortran written in VBA. Cool...
Admin