• (cs)

    First?

    And no, this is not spam, you soulcrushing scrip!

  • Mythran (unregistered)

    This comment is very important. DO NOT TOUCH!

  • NotFirst (unregistered)

    bool memberHasFirstComment = bool.Parse(bool.FalseString);

  • (cs)
    The colon is very important. DO NOT TOUCH.

    That's what she said.

  • Wormlore (unregistered)

    That is not the worst way to set a boolean to False. Something like this would have been "less good"

    bool memberHasFingerprint = !bool.Parse(bool.TrueString);

    And I'm sure someone creative enough could come up with something worst yet.

  • Rictor (unregistered)

    Seems like this programmer had a bit of a potty mouth...

    Private Function FnPtrToLong(ByVal lngFnPtr As Integer) As Integer

  • Bobbo (unregistered)
    The Article:
    # The colon is very important. DO NOT TOUCH.

    throw new AccessViolationException("Ouch, that's cold");

  • (cs)
    unless custId is 1521.
    The one constant in every software development department.
  • (cs)
    The Article:
    "This is used all over our app," writes Anthony Arnold, "I get rid of them when I see them. What's wrong with !String.IsNullOrEmpty((s ?? "").ToString())"
    public static bool IsRealString(object s)
    {
        return s != null && !String.IsNullOrEmpty(s.ToString());
    }
    
    .

    Really? Replace them when you see them? You would think there would be an automated way to "find and replace" such "atrocities" with such a useful "fix". Nevermind the fact that this fix is as least as dumb as the original. At least.

  • trwtf (unregistered)
    for (var i:int = 0; i < 100; i++){
      var rand:int = Math.random() * 6;
    }
    SoundHandler.playExternalSounds(["positive_override" + rand]); 
    
    

    The loop makes it more random, you see...

  • tim (unregistered)

    Actually I remember doing something like the 'pointer to long' in fortran on VMS once

    IIRC fortran didn't have pointers but it was possible to call C functions like malloc. however, the only way to get the return value from malloc into an int was to hide it inside an additional layer of function call because fortran is less funny about type coercions across function boundaries

    but of course if that example wasn't VMS fortran then it is a WTF ;-)

  • XX (unregistered) in reply to Wormlore

    A good developer never forgets about FileNotFound.

    bool memberHasFingerprint; try { memberHasFingerprint = bool.Parse(FileNotFoundString); catch (FormatException) { memberHasFingerprint = !bool.Parse(bool.TrueString); }

  • tim (unregistered) in reply to Wormlore
    Wormlore:
    That is not the worst way to set a boolean to False. Something like this would have been "less good"

    bool memberHasFingerprint = !bool.Parse(bool.TrueString);

    And I'm sure someone creative enough could come up with something worst yet.

    oh go on then

    bool memberHasFingerprint = (bool.Parse(bool.TrueString) == !bool.Parse(bool.TrueString))

    (i can feel the slippery slope coming on)

  • (cs)

    Aaron's code comment feel deja vu to me from one project I endured many moons ago... like man, it does speak to me, like, literally!

  • (cs)
    /*
    * See, this is why I hate my job. We start out doing some magical end-all solution for a may be customer, the
    * "XML Engine" hazily devised by IT iliterate decision makers without a clue what it's should do or who wants it. Ignore
    * that the codebase as is needs refactoring and fixing, let's ignore that we have a todo list a mile long, let's make
    * up requirements on top of that! Then, when reality kicks in and the may be customer isn't, we have semi-finished
    * shit clogging up all code arteries with poison. But noooo, don't clean it up, let's hack something else together
    * like this cover control thing, blah blah boohoo blah...
    */
    
    Sounds like this crap should be in his journal. Or if you check there maybe you'll find useful comments about the code?
  • Gary (unregistered) in reply to trwtf
    trwtf:
    for (var i:int = 0; i < Math.random() * 100; i++){
      var rand:int = Math.random() * 6;
    }
    SoundHandler.playExternalSounds(["positive_override" + rand]); 
    

    The loop makes it more random, you see...

    FTFY. Even more random now.

  • (cs)
    if (oneHundred == 100) {
       oneHundred /= 2;
    }

    Looks like oneHundred can be anything except 100.

  • digitalwitch (unregistered)
    The Article:
    "This is used all over our app," writes Anthony Arnold, "I get rid of them when I see them. What's wrong with !String.IsNullOrEmpty((s ?? "").ToString())"
    public static bool IsRealString(object s)
    {
        return s != null && !String.IsNullOrEmpty(s.ToString());
    }
    
    There is something to be said for readability. Just because you can do something in one line doesn't mean you should.
  • Anything you can do, I can do worse (unregistered)

    bool memberHasFingerprint = true; // set fingerprint presence to false...

  • Honest Guy (unregistered) in reply to frits
    The Article:
    public static bool IsRealString(object s)
    {
        return s != null && !String.IsNullOrEmpty(s.ToString());
    }
    
    public static bool IsRealString(object s)
    {
        return s // removed crap I don't understand, for readability
    }
    
  • Jellineck (unregistered) in reply to digitalwitch
    digitalwitch:
    The Article:
    "This is used all over our app," writes Anthony Arnold, "I get rid of them when I see them. What's wrong with !String.IsNullOrEmpty((s ?? "").ToString())"
    public static bool IsRealString(object s)
    {
        return s != null && !String.IsNullOrEmpty(s.ToString());
    }
    
    There is something to be said for readability. Just because you can do something in one line doesn't mean you should.

    He just learned the coalesce operator and he wants to use it everywhere.

  • Rand Dumm (unregistered) in reply to trwtf
    trwtf:
    for (var i:int = 0; i < 100; i++){
      var rand:int = Math.random() * 6;
    }
    SoundHandler.playExternalSounds(["positive_override" + rand]); 
    
    The loop makes it more random, you see...
    Shouldn't you loop a random number of times, so you don't get the same result every time you run it?
  • Anon (unregistered) in reply to frits
    The Article:
    "This is used all over our app," writes Anthony Arnold, "I get rid of them when I see them. What's wrong with !String.IsNullOrEmpty((s ?? "").ToString())"
    public static bool IsRealString(object s)
    {
        return s != null && !String.IsNullOrEmpty(s.ToString());
    }
    

    Why test if an empty string is empty (if s is null)? Seem like inlining the code from the original functions would be better. Which is probably what the compiler does anyway. And it's more readable. Once again the suggested fix is TRWTF.

  • Dazed (unregistered)

    Well, I'm all in favour of comments which explain why code was written in a particular way. Aaron's predecessor's comment isn't quite what I usually have in mind, but at least it heads off all the folks around here who cry "what the hell were they thinking?"

  • Bosshog (unregistered)
    if (oneHundred == 100) { oneHundred /= 2; }
    In Soviet Russia, Integer divides *you*.
  • (cs) in reply to DOA
    DOA:
    unless custId is 1521.
    The one constant in every software development department.

    I remember that one. French guy had to see the site in English. (some sort of language preference was just too easy)

  • Ikkonoishi (unregistered) in reply to tim
    tim:
    oh go on then

    bool memberHasFingerprint = (bool.Parse(bool.TrueString) == !bool.Parse(bool.TrueString))

    (i can feel the slippery slope coming on)

    bool memberHasFingerprint; WebClient wc = new WebClient(); string[] fs = wc.DownloadString("http://msdn.microsoft.com/en-us/library/system.boolean.truestring.aspx").Split(""",3000); foreach (string fss in fs) { if (s == bool.TrueString) memberHasFingerprint = !bool.Parse(fss); }

  • kastein (unregistered) in reply to NotFirst
    NotFirst:
    bool memberHasFirstComment = bool.Parse(bool.FalseString);

    bool memberHasFirstComment = bool.Parse(bool.FalseString);

    users.NotFirst.comment = bool.Parse(memberHasFirstComment);

  • Patrek (unregistered) in reply to Wormlore

    Got that in code I had to maintain (another language, but still):

    boolean isVerified = temp.equalsIgnoreCase("yes") ? new Boolean(true).booleanValue() : new Boolean(false).booleanValue(); 
  • Timmorn (unregistered) in reply to Honest Guy
    Honest Guy:
    public static bool IsRealString(object s)

    { return s; // removed crap I don't understand, for readability // The colon is very important. DO NOT TOUCH. }

    Fixed it for you

  • RBiter (unregistered) in reply to DOA

    .. whew! cuz I thought it was from someone in my place. I certainly recognize that number! ;

  • Pyrexkidd (unregistered) in reply to Wormlore
    Wormlore:
    That is not the worst way to set a boolean to False. Something like this would have been "less good"

    bool memberHasFingerprint = !bool.Parse(bool.TrueString);

    And I'm sure someone creative enough could come up with something worst yet.

    unless ($five_thousand != m//){
        open $FHIN, '<', "list_of_bool_values.file";
        foreach(<$FHIN>){
            &return_false;
            if ($five_thousand != $five_thousand){
                $five_thousand = "false";
            } else {
                $five_thousand = "true";
            }
        $five_thousand ? s/true//g : s/false//g;
    
    }
    
    sub return_false($){
        #So it MIGHT look like
        #this sub doesn't do anything;
        #well, actually you're right
        # but that's ok, because I checked it
        #in and our of source control for every line.
        return;
    }
    
  • Ancient Greek Guy (unregistered)
    if(person.age>18 || person.gender == female)
    {
        ewww();
    }
    else
    {
        touchColon();
    }
    
  • (cs)

    But, FnPtrToLong neither accepts nor a returns a long. Both are integers, no?

    Or was that the WTF?

  • Anon (unregistered) in reply to Ancient Greek Guy
    Ancient Greek Guy:
    if(person.age>18 || person.gender == female)
    {
        ewww();
    }
    else
    {
        touchColon();
    }
    

    Priest function?

  • Bob (unregistered)

    "[D]evised by IT iliterate[sic] decision makers without a clue what it's[sic] should do or who wants it."

    Was he being ironic?

  • forgottenlord (unregistered)
    "This is used all over our app," writes Anthony Arnold, "I get rid of them when I see them. What's wrong with !String.IsNullOrEmpty((s ?? "").ToString())"

    public static bool IsRealString(object s) { return s != null && !String.IsNullOrEmpty(s.ToString()); }

    Ok, I've never seen this operator before. Yes, it is a flash of ignorance on my part, though a quick check through the code base of my company's code (and there have been a fair number of C# developers here) I can't find a single instance of it being used. Why, we just didn't, collectively, know it. Mind you, most of us got our degrees while programming in Java or C/C++ so maybe it is just that it wasn't part of those languages. Either way, it's not really a WTF. It's a failure of knowledge rather than technique.

  • the beholder (unregistered) in reply to frits
    frits:
    The Article:
    "This is used all over our app," writes Anthony Arnold, "I get rid of them when I see them. What's wrong with !String.IsNullOrEmpty((s ?? "").ToString())"
    public static bool IsRealString(object s)
    {
        return s != null && !String.IsNullOrEmpty(s.ToString());
    }
    
    Nevermind the fact that this fix is as least as dumb as the original. At least.
    See, our store is having this great sale on sarcasm detectors...
  • NOT an ancient Greek guy (unregistered) in reply to Anon
    Anon:
    Ancient Greek Guy:
    if(person.age>18 || person.gender == female)
    {
        ewww();
    }
    else
    {
        touchColon();
    }
    

    Priest function?

    Nah, he's just an ancient Greek. It's cool. They touch the colons of boys all the time.

  • Andrew (unregistered) in reply to ContraCorners
    ContraCorners:
    But, FnPtrToLong neither accepts nor a returns a long. Both are integers, no?

    Or was that the WTF?

    It looks like RealBasic to me. RB allows mixing and matching of numeric datatypes through implicit coercion so that you can pass a 64 bit signed number (Long) to a function that accepts 32 bit signed numbers (Integer), return an Integer and treat it like a Long.

  • (cs) in reply to the beholder
    the beholder:
    frits:
    The Article:
    "This is used all over our app," writes Anthony Arnold, "I get rid of them when I see them. What's wrong with !String.IsNullOrEmpty((s ?? "").ToString())"
    public static bool IsRealString(object s)
    {
        return s != null && !String.IsNullOrEmpty(s.ToString());
    }
    
    Nevermind the fact that this fix is as least as dumb as the original. At least.
    See, our store is having this great sale on sarcasm detectors...

    Yeah I don't think so. Sarcasm involves intentional irony and humor. Show me those two elements.

  • Mordred (unregistered)

    What we are looking at here folks are samples from the pioneers of coding. If it weren't for these idiots, why we wouldn't have the super idiots we have today.

  • (cs)

    Actually, it turns out that the longer version of the IsNullOrEmpty() test that Anthony Arnold reported was needed in earlier versions of .NET. See:

    DANGER ! String.IsNullOrEmpty can lead to runtime Null exceptions !!

    So which is the bigger WTF here: Writing it this way? Or having to write it this way because your compiler doesn't optimize right?

    P.S. ...and, to top it all off, Anthony might be doing the wrong thing. Let's hope his compiler works right.

  • Anon (unregistered) in reply to forgottenlord
    forgottenlord:
    "This is used all over our app," writes Anthony Arnold, "I get rid of them when I see them. What's wrong with !String.IsNullOrEmpty((s ?? "").ToString())"

    public static bool IsRealString(object s) { return s != null && !String.IsNullOrEmpty(s.ToString()); }

    Ok, I've never seen this operator before. Yes, it is a flash of ignorance on my part, though a quick check through the code base of my company's code (and there have been a fair number of C# developers here) I can't find a single instance of it being used. Why, we just didn't, collectively, know it. Mind you, most of us got our degrees while programming in Java or C/C++ so maybe it is just that it wasn't part of those languages. Either way, it's not really a WTF. It's a failure of knowledge rather than technique.

    I don't think it existed before the introduction of nullable types in C#. I wasn't familiar with it either having start with .NET 1.0.

  • (cs) in reply to Coyne
    Coyne:
    Actually, it turns out that the longer version of the IsNullOrEmpty() test that Anthony Arnold reported was needed in earlier versions of .NET. See:

    DANGER ! String.IsNullOrEmpty can lead to runtime Null exceptions !!

    So which is the bigger WTF here: Writing it this way? Or having to write it this way because your compiler doesn't optimize right?

    P.S. ...and, to top it all off, Anthony might be doing the wrong thing. Let's hope his compiler works right.

    Anthony's method is functionally equivalent as far as null checking goes. TRWTF is having a method called "IsRealString" that checks an object instead of a string. In other words, the call to .ToString() is the fly in the ointment here.

  • (cs) in reply to frits
    frits:
    Yeah I don't think so. Sarcasm involves intentional irony and humor. Show me those two elements.
    Not an easy task. Sure, one can show humor simply by laughing (ha), and it's clear that the "fix" was ironically as bad or worse than the original (you've admitted that yourself). However, the challenge lies in proving that these traits were intentional. Certainly the reader inferring the submitter's intentions would be subjective, and therefore worthless. What we need is some form of empirical evidence proving that the submitter intended to be ironic and humorous, or that said irony/humor was purely accidental. This may take a while.

    Oh, wait. This is a forum on the internet, so no one cares.

    My mistake.

  • ÃÆâ€â„ (unregistered)

    What, so you guys don't touch your colons? Boy, are you missing out.

  • Two (unregistered) in reply to DOA
    DOA:
    unless custId is 1521.
    The one constant in every software development department.

    oracleDbPortNum = 1521

  • yetihehe (unregistered)
    <?php include sitename(__COMMENT__).'/../../../omgponies.com/public_html/comment_view.php'; ?>

    on the other hand, they could do it like this: eval(file_get_contents('othersite'));

  • Two (unregistered) in reply to ShatteredArm
    ShatteredArm:
    if (oneHundred == 100) {
       oneHundred /= 2;
    }

    Looks like oneHundred can be anything except 100.

    Unless it starts out at 200 ...

Leave a comment on “CompareObjectAsIAlertDocumentOrNullIfNotCastable and More”

Log In or post as a guest

Replying to comment #:

« Return to Article