• (nodebb)

    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

  • my name is missing (unregistered)

    What happens if the status code is 11?

  • (nodebb)

    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.

  • markm (unregistered)

    The temporary variable 'statuscode' seems to be a minor WTF. Or does this language (Python?) rule out:

    Select Case Me.ddlStatus.SelectedItem.Value
    
  • ooOOooGa (unregistered) in reply to markm

    this language (Python?)

    Not Python. Not nearly enough colons for Python.

    'Dim' screams Visual Basic to me.

  • Barry Margolin (github) in reply to markm

    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.

  • kaewberg (unregistered)

    Abstract out repeated code:

    if condition then doStuff() else doStuff() end

    Much better!

  • Argle (unregistered) in reply to kaewberg

    All too often I've seen:

    if (complex series of tests) then -- commented out code else -- more commented out code

  • Alipha (unregistered)

    What The Daily WTF needs is to post the fixed/improved code, when applicable. The code in the post could be reduced to simply:

    Dim statuscode As Integer = Me.ddlStatus.SelectedItem.Value
    	
    Select Case statuscode
    	Case 2
    		' snip a few lines of code
    		Me.In_Preparation()
    	Case 3
    		Me.In_Fabrication()
    	Case 5
    		Me.Sent()
    	Case 7
    		Me.Rejected()
    	Case 8
    		Me.Cancel()
    	Case 10
    		Me.Waiting_for_payment()
    End Select
    
  • I reboot (unregistered)

    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.

  • (nodebb)

    Lines got written and copy/pasted and re-written until it worked, the developer committed the code, and nobody thought anything more about it, if they thought anything in the first place.

    ITYM:

    Lines got written and copy/pasted and re-written until it worked, the developer committed suicide, and nobody thought anything more about it, if they thought anything in the first place.

  • (nodebb) in reply to ooOOooGa

    'Dim' screams Visual Basic to me.

    It's tagged in the HTML source as vbscript.

  • I Read The Comments (unregistered)

    Maybe once in the past there was different code in both blocks? Code changes without proper analysis made this, so...

  • Chris (unregistered)

    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?"

  • Paul (unregistered) in reply to dkf

    I don't think highlightjs (dot org) has an actual preset for Basic. vbscript is close enough for highlighting though.

  • Neveranull (unregistered)

    There’s no budget to refactor working code.

  • Alex (unregistered) in reply to Neveranull

    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.)

Leave a comment on “A Select Sample”

Log In or post as a guest

Replying to comment #536554:

« Return to Article