• Kanitatlan (unregistered)

    I was more amused when I once (long, long time ago) found a header file with the following

    DEFINE ZERO "1";

  • Cpt. Obvious (unregistered)

    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

  • bvs23bkv33 (unregistered) in reply to Kanitatlan

    explicit: if you write #define ZERO\n it will be also defined as 1

  • Little Bobby Tables (unregistered) in reply to Kanitatlan

    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.

  • RLB (unregistered) in reply to bvs23bkv33

    In what language? In C, it will be defined, but without a value.

  • Charles F. (unregistered) in reply to RLB

    It's C#.

    I don't know C# myself, so I wonder if

    (True == "True") == true

    would be "true."

  • C# Guru (unregistered) in reply to Charles F.

    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.

  • Prash (github)

    I don't see why this is bad code if those strings are legitimately needed. They can prevent typos compared to repeating string literals.

  • (nodebb)

    The submitter (or the editor?) left out three lines:

    public const string False = "False";
    public const string FILENOTFOUND = "FILENOTFOUND";
    public const string FileNotFound = "FileNotFound";
    
  • Mike Rosoft (unregistered)

    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.

  • MiserableOldGit (unregistered)

    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.

  • Simon Clarkstone (unregistered) in reply to Prash

    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.

  • JG (unregistered)

    I think the worst I've actually seen in production is

    insert into table values (1, 2, 'NULL')

  • eric bloedow (unregistered)

    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!

  • Jaloopa (unregistered) in reply to eric bloedow

    I wonder where you might have heard that

    https://thedailywtf.com/articles/Elegant-Syntax-Error

  • (nodebb)

    public string "True" = "Fake News"

  • I am a robot (unregistered)

    My coworker did this #define ZERO 11

  • Developer Dude (google) in reply to P. Wolff

    and:

    paula = "Brillant";

  • Duke of New York (unregistered)

    seems like an overreaction

  • (nodebb)

    I once saw a file that said Midnight was 8:00pm

  • boolean (unregistered)

    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.

  • (nodebb) in reply to slapout1

    But 8:00 PM is midnight, in Zulu time, when the system is running EDT.

  • bill (unregistered) in reply to CoyneTheDup

    If you don’t take DST into account 🤔

  • shcode (unregistered) in reply to Prash

    prash, are you, by any chance, from india?

  • shcode (unregistered) in reply to Duke of New York

    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.

  • Left out (unregistered) in reply to P. Wolff

    Not just three. They left out 12997 lines. For the sake of our eyes. Thank them.

  • Chris (unregistered)

    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?

  • Little Bobby Tables (unregistered) in reply to Jaloopa

    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.

  • RLB (unregistered) in reply to Little Bobby Tables

    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.

  • Klaus (unregistered) in reply to Mike Rosoft

    That interpretation seems depressingly likely. Overengineered rules could cause damage like that...

  • Ulysses (unregistered)

    I submitted a good WTF article ages ago, but flavorless crud like this continues to get posted. Sigh.

  • John (unregistered)

    FWIW C# also has Boolean.TrueString == “True” == true.ToString() and Boolean.FalseString == “False”

    Oddly, Boolean.FileNotFound is missing

Leave a comment on “Constantly True”

Log In or post as a guest

Replying to comment #498281:

« Return to Article