• (nodebb)

    And the code is also a double WTF in its own right.

    Frist of all, it does all that "if boolean_thing return true else return false" junk that's rightly noted in the article.

    Snecod, it also compares completed explicitly to true which is a strong WTF in languages that don't have an "enforcing" boolean type. (C++ bool is an enforcing type, olde skoole C use of int is not.)

  • some guy (unregistered)

    There needs to be parsing of "True" to true. After all, what better way to ensure readability than through parseability!!!

  • TS (unregistered)

    They don't care enough about readability standards to use names such as IsCompleted, then?

  • (nodebb)

    I cannot tell which language that should be.

    It ain't C#, cause while the language uses Pascal case for public members, this should be a property and the backing field should be labeled either with the prefix m_, s_ or _.

    It ain't C++, cause there's no colon after public and methods are generally snake case.

    It ain't Java, cause the method would be camel case and they generally put this in front of every member scoped property.

    I guess it's yet another excellent example, why the language should be tagged in articles :-)

    My personal guess it looks like a Java developer tried to write C# code while thinking about C++.

    Addendum 2026-03-23 08:08: BTW the proper C# code would like this, if it is actually C#:

    public bool Completed { get; private set; }

  • (nodebb)

    I'm pretty sure it's C#.

  • (nodebb) in reply to MaxiTB

    It's perfectly valid C#.

  • (nodebb) in reply to MaxiTB

    Properties in C# are syntactic sugar so the code gets compiled into a getter anyway which is why in this case is just simpler to clean the method's code:

    public bool Completed() => completed;
    

    That usually compiles into this:

    mov al, byte ptr [rcx+OFFSET]
    ret
    

    which the compiler usually inlines in release configurations because it is way faster than a call and in some instances shorter as well (a call is 5 bytes and a the mov is 3 if the OFFSET <= 0x7F and 6 otherwise). I'm assuming x64 and ignoring the aligment because .NET will align values in memory so a lone bool might compile to a 32 bit integer instead of an 8 bit one, depending on how and where it was declared.

  • LegacyWarrior (unregistered)

    These standards always come from a place of good intention, although sometimes misplaced. I've also been guilty of defining "standards" or "best practices" that ended up less useful than intended. I think "The Real WTF" is either the disfunction in Tony's organization or their inability to discuss, reassess, and redress those "standards" and move forward.

  • (nodebb)

    Guys, I'm pretty sure the "completed" variable was altered from the original code. There was probably some huge logic block above this stupid return part that would set a local boolean named "completed" to true/false.

  • (nodebb)

    Takes no parameters, so "completed" is a static boolean?

  • (nodebb) in reply to AGlezB

    Properties in C# are syntactic sugar

    No, they are not. They generate actual type information (aka can be reflected AS properties) and don't behave the same way as methods do, because they are inlined by default to their backing field even over assemblies. You can simply not get the same result with methods.

  • Angela (unregistered)

    Heh, and our standard is that you can't have more than one "return", so this would completely fail at my location.

  • (nodebb)

    I still prefer using if expression return true else return false because I find it easier to read and debug, but how much it helps is proportional to how complex expression is. If it's a single variable, especially just an instance variable, then yeah, it doesn't really make much difference.

    But if variable == true is just stupid.

  • (nodebb) in reply to MaxiTB

    The languages you mentiones (C#, C++, Java) make no requirement on the case of identifiers. Case and naming conventions, are just that: conventions. And typically spelled out in a coding standard or guideline. And we can see what kind of coding standard is in use at this poor submitter's company.

    Addendum 2026-03-23 11:14: s/mentiones/mentioned

    Apologies for the typo.

  • (nodebb)

    The code is not the same as just returning completed. The code as written returns false when cmpleted is FileNotFoud.

    Addendum 2026-03-23 11:18: s/cmpleted/completed/

  • (nodebb) in reply to MaxiTB

    Your reasoning for why the code is not C# and not Java is fallacious because you list naming conventions not syntax rules. Neither compiler cares about capitalisation of identifiers or those horrible prefixes.

  • Fred (unregistered) in reply to Steve_The_Cynic

    Another is that the boolean variable being interrogated is not a parameter, it appears to be a global.

  • (nodebb)

    This looks like somebody being paid by the line. Could have made even more by writing "return true" and "return false" on two lines each.

  • (nodebb) in reply to MaxiTB

    That's incorrect. Whether a method is inlined does not depend on whether it's a property accessor or not. Yes, properties do generate metadata, but it doesn't affect anything else, really. You could have .NET without property metadata and with explicitly defined access methods, and it would only change the invocation style. Properties (and events) are basically syntactic sugar, which is supported by the language and the framework.

  • (nodebb) in reply to Fred

    Another is that the boolean variable being interrogated is not a parameter, it appears to be a global.

    It might also be an instance variable ("member variable" in C++ terms).

    But also don't forget that we don't see what lies between the opening brace and the beginning of the if(), wherein completed might be a local variable.

  • (nodebb) in reply to sudgy

    Could have made even more by writing "return true" and "return false" on two lines each.

    You lack ambition. You could use three lines each, thusly:

        if ( completed == true )
        return
        true
        ;
        else
        return
        false
        ;
    
  • (nodebb)

    And I also lack ambition, because the if() line could be written across six lines...

  • A Human (unregistered) in reply to MaxiTB

    I feel that that logic is flawed. Especially when the whole WTF is about poor code style, I don't think it's reasonable to infer the language from the naming convention, because they are, well, conventions. One is not forced to use such conventions---I personally use snake case when writing java because I do not believe in f@#$ing hungarian notation.

  • Jimbob (unregistered)

    Strict coding standards typically reduce the readability of code by reducing ways for the developer to express its meaning. This is just a particularly obvious example of that.

Leave a comment on “Completely Readable”

Log In or post as a guest

Replying to comment #693536:

« Return to Article