- 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
Edit Admin
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
completedexplicitly totruewhich is a strong WTF in languages that don't have an "enforcing" boolean type. (C++boolis an enforcing type, olde skoole C use ofintis not.)Admin
There needs to be parsing of
"True"totrue. After all, what better way to ensure readability than through parseability!!!Admin
They don't care enough about readability standards to use names such as IsCompleted, then?
Edit Admin
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; }Edit Admin
I'm pretty sure it's C#.
Edit Admin
It's perfectly valid C#.
Edit Admin
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:
That usually compiles into this:
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
movis 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 loneboolmight compile to a 32 bit integer instead of an 8 bit one, depending on how and where it was declared.Admin
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.
Edit Admin
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.
Edit Admin
Takes no parameters, so "completed" is a static boolean?
Edit Admin
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.
Admin
Heh, and our standard is that you can't have more than one "return", so this would completely fail at my location.
Edit Admin
I still prefer using
if expression return true else return falsebecause I find it easier to read and debug, but how much it helps is proportional to how complexexpressionis. If it's a single variable, especially just an instance variable, then yeah, it doesn't really make much difference.But
if variable == trueis just stupid.Edit Admin
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.
Edit Admin
The code is not the same as just returning
completed. The code as written returnsfalsewhencmpletedisFileNotFoud.Addendum 2026-03-23 11:18:
s/cmpleted/completed/Edit Admin
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.
Admin
Another is that the boolean variable being interrogated is not a parameter, it appears to be a global.
Edit Admin
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.
Edit Admin
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.
Edit Admin
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
completedmight be a local variable.Edit Admin
You lack ambition. You could use three lines each, thusly:
Edit Admin
And I also lack ambition, because the if() line could be written across six lines...