• (nodebb)

    This is probably a container of some sort, perhaps a "section" - thin border with the title in top left corner - the Text property is the title and disabling it disables all the controls inside of it.

  • Zatapatique (unregistered) in reply to Mr. TA

    I think you mean a fieldset, not a section.

  • (nodebb)

    This really looks like it ought to be inside a looping construct that iterates though the collection of widgets looking for the one whose text is "Original"/"Originale". Or is a separate method called from a looping construct.

    After all, very few UI objects are actually named "item". that just screams "output of iterator" to me.

  • Brian Boorman (unregistered)

    FreeBSDGuy? Is BSDGuy in jail or something? Why do we need to free him?

  • (nodebb)

    I profess I don't get how people write code like this, the logic is very clear that all roads lead to false, so why keep the useless code? Perhaps they were paid by the line?

  • Jason Stringify (unregistered)

    It always annoys me when people put parentheses around simple conditions in VB If statements. You are not writing C: use the idioms of the language you're using.

  • Jaloopa (unregistered) in reply to mynameishidden

    The nested ifs mean it's not always going to disable it. It's equivalent to

    If (gLang = "en" AndAlso item.Text.Equals("Original")) Then
            item.Enabled = False
    ElseIf (gLang = "fr" AndAlso item.Text.Equals("Originale")) Then
            item.Enabled = False
    ElseIf (item.Text.Equals("Original")) Then
            item.Enabled = False
    End If
    
  • Conradus (unregistered) in reply to Brian Boorman

    FreeBSDGuy from chroot jail!

  • Nonymous (unregistered)

    I will give the original author some internet points for thinking about future extensibility when they added that Else block. Surely, French is the only weird language out there, so if we ever need to support any others, they will use the word "Original" for this.

  • Hal (unregistered) in reply to Jason Stringify

    I always used parens in VB, never did VB.NET, I tend to put them in Ruby as well; which all the rubists hate.

    I like them though it makes it a lot easier to visually reason about any compound conditionals, and avoids a lot of operator precedence questions. Should you know how to evaluate precedence in the language you are using yes; but honestly even the best of us can get tripped if are in a role that has us frequently switching languages.

    It makes more sense to use them most of the time to me than it does to use them just some of the time. The exception I think should be for a single value, treated as a boolean, 'if (x.nil?)' does look kinda stupid

  • Foo AKA Fooo (unregistered) in reply to Jaloopa

    Not equivalent. Your code got the "else" relations wrong. In particular, if gLang = "fr" and item.Text.Equals ("Original"), your code would set it to False whereas the original (pun intended) code wouldn't (correctly).

    Always nice to the when WTFiness of code can still be improved in the comments. In this spirit, I'd like to propose adding the following to cover German too (and make it more WTF-idiomatic, as per Jason Stringify's comment):

    ElseIf ((gLang = "de") = (True)) Then
        If ((item.Text.Equals("Original")) = (not False)) Then
            item.Enabled = (1 = 0)
        End If
    
  • TheCPUWizard (unregistered)

    Until it is realized that "somewhere" there is obscure code that will item.Text = "Copy" and that edit broke that use case...

  • (nodebb)

    I've sold this application to an German company, and promised a full translation. Delivery date is the first of next month.

  • Officer Johnny Holzkopf (unregistered) in reply to Foo AKA Fooo

    If you do it wronglyworthy, do it right: If ((item.Text.Equals("Original")) = (not (False))) Then. Or else.

  • (nodebb)

    FreeBSDGuy? Is BSDGuy in jail or something? Why do we need to free him?

    He's in jail(8), not jail, so all OK.

  • Foo AKA Fooo (unregistered) in reply to Brian Boorman

    Because he was malloc'd.

  • löchlein deluxe (unregistered)

    I'm sure we can do something nice with map and zip if we had all the translations in a dict.

    (And I know – and have occasionally been – the kind of programmer that goes "there's tutorials for i18n, so obviously that's complicated, I'm at maximum depth of my mental call stack anyway, I'll just cobble something up". Which is why you should have enough non-billable time to identify(!) and fix technical debt.)

  • Craig (unregistered)

    Re the comment about "label doesn't allow editing", that's true, but Enabled still has a meaning for labels. It will change the UI to make it gray to give a visual cue that the associated item isn't active.

Leave a comment on “Some Original Code”

Log In or post as a guest

Replying to comment #:

« Return to Article