- 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
Admin
I was more amused when I once (long, long time ago) found a header file with the following
DEFINE ZERO "1";
Admin
Meh. There's plenty of IDEs that'll end up doing stuff like that for you - hunt through the codebase, finding repeated strings and externalizing them to constants. Not a massive WTF
Admin
explicit: if you write #define ZERO\n it will be also defined as 1
Admin
Possibly a cack-handed attempt to make an application change mode, from "Dev" mode to "Test" or "Prod" mode, for example, where the stupid programmer had defined the modes by integer and then named the mode stupidly. Rather than go through and hunt for everywhere the mode was invoked, the maintenance man just decided: f%&k it, change it in the Define block. WTF upon WTF.
Admin
In what language? In C, it will be defined, but without a value.
Admin
It's C#.
I don't know C# myself, so I wonder if
(True == "True") == true
would be "true."
Admin
In this case (True == "True") == true will always be true.
The constant True has the value "True" so the statement in brackets evaluates to true. And true should be true (meaning true === true) in all languages.
Admin
I don't see why this is bad code if those strings are legitimately needed. They can prevent typos compared to repeating string literals.
Admin
The submitter (or the editor?) left out three lines:
Admin
Yeah, this is what you get when corporate enforces the rule that literal values must not be used and instead one has to use named constants. (And then, for additional madness, they get an idea that every public member needs to have XML documentation comments.)
And I strongly suspect that the constants are really pointless anyway; they are used in place of bool.TryParse / bool.ToString.
Admin
Looks clumsy and amateurish, but fairly mild compared to some of the rubbish I've seen. I do hope he switches one to True="False" before he goes, just for giggles.
Admin
That's a good idea.
OTOH in that case they are probably part of a configuration XML/JSON/whatever language and should be something like "KEYWORD_TRUE" or "ATTRIBUTE_TRUE" and suitably commented. OTOOH, you can track down all the code that uses them more easily than for a plain string constant.
Admin
I think the worst I've actually seen in production is
insert into table values (1, 2, 'NULL')
Admin
i remember an old story: a guy had the silly habit of pretentiously writing "whilst" instead of "while" in his programs, but SOMEHOW got it to work...it turned out his secret was a hidden [public const string whilst="while"] command!
Admin
I wonder where you might have heard that
https://thedailywtf.com/articles/Elegant-Syntax-Error
Admin
public string "True" = "Fake News"
Admin
My coworker did this #define ZERO 11
Admin
and:
paula = "Brillant";
Admin
seems like an overreaction
Admin
I once saw a file that said Midnight was 8:00pm
Admin
Sure, this would be a WTF if they were being used as booleans in code. But we don't have that context, do we? How do you know they weren't actual string literals that were needed, like a True/False quiz where those strings need to be shown on screen? FWIW we have similar constants in our code, except our code is an XML parser and they are used for parsing xs:boolean type attributes from text.
Admin
But 8:00 PM is midnight, in Zulu time, when the system is running EDT.
Admin
If you don’t take DST into account 🤔
Admin
prash, are you, by any chance, from india?
Admin
Duke of New York not at all an overreaction if there was a False as well, it would be a dailywtf-submission worthy
but, missing the PascalCase false makes it into an immediate resignation material for me too.
Admin
Not just three. They left out 12997 lines. For the sake of our eyes. Thank them.
Admin
I can forgive a definition for TRUE = "TRUE", or True = "True", but not both. Because now TRUE != True. Which true do you need in any given situation?
Admin
This also reminds me of a story where an English major found herself in a programming position, and insisted on writing things like,
someMethod ("String Parameter," param2)
on the grounds that it's grammatically incorrect to put the comma outside of the quote marks when quoting speech.
The fact that she could never get her code to compile was subordinate to her insistence on her computer being taught accurate grammar.
Admin
Shows how much English majors know about their own subject. In many dialects of English, including the real one (but apparently not the Colonial one), punctuation marks go outside the quotation marks unless they're part of the quoted material.
Admin
That interpretation seems depressingly likely. Overengineered rules could cause damage like that...
Admin
I submitted a good WTF article ages ago, but flavorless crud like this continues to get posted. Sigh.
Admin
FWIW C# also has Boolean.TrueString == “True” == true.ToString() and Boolean.FalseString == “False”
Oddly, Boolean.FileNotFound is missing