- 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
If you want beef, then choose beef, chicken, lamb or fish; if you hate beef, then choose beef, chicken, lamb or fish.
Speaking of which, mmmmm lamb
Admin
What happens if the status code is 11?
Admin
This is what happens when users insist on handling certain conditions - unless they don't want it - and then decide they always want it - until they don't anymore. The If/Then/Else is coded like this so they can comment the Else block for all Me.ddlStatus.SelectedItem.Value that does not equal 2 when the users decide they don't want it. Until they do. Then the Else block gets uncommented.
Happens all the time when Enterprisey meets WTFery.
Admin
The temporary variable 'statuscode' seems to be a minor WTF. Or does this language (Python?) rule out:
Admin
Not Python. Not nearly enough colons for Python.
'Dim' screams Visual Basic to me.
Admin
It's some flavor of BASIC, probably Visual BASIC. You can always recognize BASIC from its use of
DIM
. BASIC was my first language (back in the late 70's), and this has always irked me. It came from declaring the dimensions of arrays, and was then coopted as the general declaration statement.Admin
Abstract out repeated code:
if condition then doStuff() else doStuff() end
Much better!
Admin
All too often I've seen:
if (complex series of tests) then -- commented out code else -- more commented out code
Admin
What The Daily WTF needs is to post the fixed/improved code, when applicable. The code in the post could be reduced to simply:
Admin
Because the variable is "Me," I feel so much deeper emotion when reading this code. In the end, though, Me is just waiting for payment, which makes it all feel so cheap and wrong.
Admin
ITYM:
Admin
It's tagged in the HTML source as vbscript.
Admin
Maybe once in the past there was different code in both blocks? Code changes without proper analysis made this, so...
Admin
It's like they heard someone talk about loop unrolling once, and someone else mentioning that switch statements can be more performant than if-else statements, and pre-optimisation being... something... and thought this code was somehow a good thing.
I can even imagine this programmer, upon having the stupidity of the logic pointed out to them, scoffing and saying "it works though, so why does it matter?"
Admin
I don't think highlightjs (dot org) has an actual preset for Basic. vbscript is close enough for highlighting though.
Admin
There’s no budget to refactor working code.
Admin
More importantly, there's no budget to test the refactored code.
The company is clearly making use of VB's "object oriented" (heh) features - the "Me" keyword can only appear inside class modules - so for all we know Me.ddlStatus.SelectedItem.Value could return different values on subsequent reads. That's something that in a sane organisation would be picked up by both a scan of the documentation and a broken unit test... but a sane organisation, run by people who understood the concept of technical debt, probably wouldn't be using VBScript nor producing code of this quality.
So it's entirely possible that, by fixing this, Henry would end up breaking ALL TEH THINGZ... and the first anyone would know about it was when customers started calling up to complain.
This is why, when I start at a new place with this kind of mentality - which is all of them cos I work in financial reporting - the second thing I do is figure out if they've got any sort of actual testing plan for system changes. If not, I mentally double my time estimates for any change and quadruple the standard deviation of those estimates.
(The first thing I do is check whether they've got an issue tracker I can use to log their lack of an adequate testing plan. That's so I can point at it later when, despite my best efforts, this inevitably bites us.)