• snoofle (unregistered)

    I see the truth - this is for those tribool cases where File-Not-Found just won't do!

  • Sad (unregistered)

    Better yet:

    private static bool GetTrue() { return false; }

    I leave the third alternative an exercise to the reader.

  • gygax (unregistered)

    Truly enlightening.

  • Coditor (unregistered)

    Just in case you ever decide that TRUE isn't "true"... you'd only have to change this function instead of a global search/replace in all your code... Makes perfect sense ^.-

  • Strider (unregistered)

    I don't understand what the WTF is...this is obviously a master of soft coding at work. I mean, who hard codes boolean values these days anyway?

    captcha: muhahaha, nuff said

  • Sad (unregistered) in reply to snoofle
    snoofle:
    I see the truth - this is for those tribool cases where File-Not-Found just won't do!
    The Windows API has precisely this kind of "triboolean" function. GetMessage() returns a BOOL that can be TRUE, FALSE, or -1. Go figure!
  • Stephen Sweeney (unregistered) in reply to Sad
    Sad:
    Better yet:

    private static bool GetTrue() { return false; }

    I leave the third alternative an exercise to the reader.

    // // You can't handle the truth :) // private static bool GetTrue() { System.exit(1); }

  • JOHN (unregistered)

    The REAL WTF is stereotyping goths as "fat weirdos who worship satan".

    "TheDailyWTF" is too offensive because of the "F", but it's just fine to stereotype?

    WorseThanFailure = worse than failure.

  • (cs) in reply to JOHN

    I just found this in the code I'm working on.

    static char* Dash_I = "-I"; static char* Dash_D = "-D"; static char* Dash_A = "-A"; static char* Dash_P = "-P";

    (...)

  • Winter (unregistered)

    This fulfils the code equivalent of the nerd stereotype for saying "for a given value of true"

    if anyone mentions file_not_found I'm going to shoot a puppy

  • (cs)

    he didn't stereotype goths as fat weirdos who worship satan.

    He stereotyped fat goth weirdos as satan worshippers. If you are going to get your panties in a bunch, at least be accurate about it.

  • (cs) in reply to JOHN
    JOHN:
    The REAL WTF is stereotyping goths as "fat weirdos who worship satan".

    If it helps, I don't associate goths with satan worshippers. I would just make it "pale, fat weirdos" but then the religious context is lost.

  • whicker (unregistered) in reply to JOHN
    JOHN:
    The REAL WTF is stereotyping goths as "fat weirdos who worship satan".

    "TheDailyWTF" is too offensive because of the "F", but it's just fine to stereotype?

    WorseThanFailure = worse than failure.

    What about the crazy "crazy celebrities in Xenu" crazy statement. That's just craaaaaaazy.

  • Dave (unregistered) in reply to JOHN
    JOHN:
    The REAL WTF is stereotyping goths as "fat weirdos who worship satan".

    "TheDailyWTF" is too offensive because of the "F", but it's just fine to stereotype?

    WorseThanFailure = worse than failure.

    Spoken like a true fat weirdo who worships satan :P

  • Spiceweasel (unregistered)

    Alas, the truth is out of scope for me. Forsooth! 'Tis declared private!

  • Not First (unregistered) in reply to Stephen Sweeney
    Stephen Sweeney:
    Sad:
    Better yet:

    private static bool GetTrue() { return false; }

    I leave the third alternative an exercise to the reader.

    // // You can't handle the truth :) // private static bool GetTrue() { System.exit(1); }

    yeah, but how are you supposed to test it? This is much better.

    private static bool GetTrue() { IoCContainer myContainer = Configuration.GetContainer(); Object oFact = myContainer.GetObject("IFactFactory"); IFactFactory fact = (IFactFactory) oFact; Object oConfig = myContainer.GetObject("IFactConfiguration"); IFactConfiguration config = (IFactConfiguration) oConfig; IFactResolver resolver = fact.CreateFactResolver(config); return resolver.GetBooleanResultProvider().GetTrue(); }

  • Blue (unregistered)

    private static bool GetTrue() { return File_Not_Found; }

  • (cs)

    I'd like to see a use case for this.

    I've wrote this exact same function a few weeks ago for testing purposes. I was testing a function that took a function pointer as an argument and wanted to test it against a function that always returned true.

    In effect its a mock function (as apposed to a mock object).

  • Skizz (unregistered)

    It must be a Scientology class as the truth is private and only accessable to members or friends.

  • kupal (unregistered)

    how bout

    private static bool GetTrue() { return !false; }

    or

    private static bool GetTrue() { return true == true; }

    or

    private static bool GetTrue() { return true.Equals(true); }

    or

    private static bool GetTrue() { return "maybe I should stop" != string.Empty; }

    i could go on and on, you see there are many variations of the truth

  • (cs) in reply to JOHN
    JOHN:
    The REAL WTF is stereotyping goths as "fat weirdos who worship satan".

    "TheDailyWTF" is too offensive because of the "F", but it's just fine to stereotype?

    WorseThanFailure = worse than failure.

    Failure to read the article before calling "hate crime" = worse than failure.

    The article reads:

    fat goth weirdos [seek truth and enlightenment] in Satan.
    Whereas you seem to have read:
    All goths are fat weirdos who seek truth and englightenment in Satan

    These two statements are not the same.

  • (cs) in reply to JOHN
    JOHN:
    The REAL WTF is stereotyping goths as "fat weirdos who worship satan".

    "TheDailyWTF" is too offensive because of the "F", but it's just fine to stereotype?

    WorseThanFailure = worse than failure.

    Damn right. Many Goths don't really worship Satan.

    And much as Alex can be commended for his unwavering perseverance in this matter, I really don't know anyone else who takes the "worse than failure" silliness seriously. A WTF is a WTF and that's that. You can call your new kitten "dog", that doesn't make it one.

  • (cs)

    In relation to the 'You can't handle the truth' comment, found within our test code:

    ... assertFalse("Oops!", !(!booleanFlag)); ...

    I only assume this particular snippet started it's prolific life as the following:

    ... assertFalse("Oops!", booleanFlag); ...

    and, that after careful research and testing, it was found that jUnit's 'assertTrue()' call wasn't nearly as reliable as 'assertFalse()'. In fact, this was so carefully tested that it has been repeated thousands of times within the code base.

    I won't even get into the number of occasions where the booleanFlag is assigned and then immediately asserted. It would seem we can't even trust the JVM anymore.

  • (cs) in reply to th0mas
    th0mas:
    I just found this in the code I'm working on.

    static char* Dash_I = "-I"; static char* Dash_D = "-D"; static char* Dash_A = "-A"; static char* Dash_P = "-P";

    (...)

    Whoever wrote that was likely passing those character constants to a function that didn't take const arguments because "const is too hard."

  • (cs) in reply to JOHN
    JOHN:
    The REAL WTF is stereotyping goths as "fat weirdos who worship satan".

    "TheDailyWTF" is too offensive because of the "F", but it's just fine to stereotype?

    WorseThanFailure = worse than failure.

    So...

    You are into goth

  • Angel (unregistered)

    They don't even test the true value before they return it ... it should have been

    private static bool GetTrue() { if (true) { return true; } elseif (true == true) { return true; } elseif (true == false) { return false; } else { return (false == true); } }

  • Patrik (unregistered)

    This makes perfect sense for use in a boolean returning callback function. GTK+ has gtk_true() and gtk_false() for exactly that usage, for example.

  • (cs)

    I had some theories about how this could be useful function, but they all vanished when I read again the declaration "private static"

  • Steve (unregistered)

    I won't swear this is true since it appears in the Unix fortune program's database of jokes, silliness, and pithy quotes but it's still amusing:

    The primary purpose of the DATA statement is to give names to constants; instead of referring to pi as 3.141592653589793 at every appearance, the variable PI can be given that value with a DATA statement and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of pi change. -- FORTRAN manual for Xerox Computers
  • JF (unregistered)

    private static String IsReadyForEnligthment(String sName) {

    if (getTruth()) Return sName + "is ready for enligthment"; else return "PEACHES!!!" }

  • (cs) in reply to Skizz
    Skizz:
    It must be a Scientology class as the truth is private and only accessable to members or friends.
    You just about made coffee come out my nose!
  • Calli Arcale (unregistered) in reply to Steve
    Steve:
    I won't swear this is true since it appears in the Unix fortune program's database of jokes, silliness, and pithy quotes but it's still amusing:
    The primary purpose of the DATA statement is to give names to constants; instead of referring to pi as 3.141592653589793 at every appearance, the variable PI can be given that value with a DATA statement and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of pi change. -- FORTRAN manual for Xerox Computers

    pi is a mathematical constant and therefore will never change, but the precision of it might. So the value your program actually uses for pi may well change.

    After all, 3.14 and 3.14159 are not the same thing -- but both are legitimately used as values of pi.

  • Zygo (unregistered) in reply to livid
    livid:
    I won't even get into the number of occasions where the booleanFlag is assigned and then immediately asserted. It would seem we can't even trust the JVM anymore.

    Sounds like one of my CS courses. The first lecture covered invariants, preconditions, postconditions, and classes. Every subsequent assignment, test, midterm, and exam required slavish documentation of all of these, and implementation of them in code, so every method, no matter how trivial, looked like:

    /* private */ void SomeClass::setEmpty() {
        assert(isEmpty == true || isEmpty == false); // invariant
        // not shown here: about 10 other asserts for the rest of the invariant conditions
        assert(isEmpty == true || isEmpty == false); // precondition
        isEmpty = true;
        assert(isEmpty == true);                     // postcondition
        assert(isEmpty == true || isEmpty == false); // invariant
        // not shown here: about 10 other asserts for the rest of the invariant conditions
    }
    

    Leaving out one or two of these asserts would quickly dimish the author's overall mark by almost half, so we learned to write this crap every single time (yes, including the two identical asserts documented separately as preconditions and invariants). The "== true" form was required since we weren't allowed to take advantage of bool/integer equivalence even if it is a documented feature of an international standard.

    That kind of thing can scar you for life. It took years to break out of that habit. (Well, OK, maybe the third week of the next term, when the academic focus shifted to new topics, and we made a deal with the TA who was as sick of reading this crap as we were of writing it...)

  • (cs)

    And, of course, we're getting Google ads about the Song of Solomon.

  • (cs) in reply to JF
    JF:
    private static String IsReadyForEnligthment(String sName) {

    if (getTruth()) Return sName + "is ready for enligthment"; else return "PEACHES!!!" }

    But what about pudding??

    I keep responding to the gold spammers in Wow with pudding. They don't seem to like it much and never respond. :( Pudding is always the red-haired stepchild of the family.

    -- Seejay

  • Zygo (unregistered) in reply to Patrik
    Patrik:
    This makes perfect sense for use in a boolean returning callback function. GTK+ has gtk_true() and gtk_false() for exactly that usage, for example.

    I was about to use some STL examples of boolean functors, but you beat me to it.

    C++ code is full of creatures like this, because function objects are the arguments of so many methods, classes, and functions. Other examples:

    • the "identity" functor, a unary function that returns its own argument.
    • the "noop" functor, a unary function that ignores its argument and returns nothing.
    • the "constant" functor, a zero-argument function that returns its constructor argument value over and over.
  • Paul Evans (unregistered)

    I suggest in fact, we need a complete interface, consisting of the following methods:

    private static bool getTruth();

    private static Set<bool> getWholeTruth();

    private static Set<bool> getNothingButTruth();

  • Droom (unregistered)

    I think that in order to truly explore the philosophical implications of the enduring and never-ending search for truth, this function must be recursive.

  • Zygo (unregistered) in reply to Jojosh_the_Pi
    Jojosh_the_Pi:
    And, of course, we're getting Google ads about the Song of Solomon.

    We are? Maybe you are, but I'm not:

    Ads by Google:
    Flying Spaghetti Monster Pastafarians Unite. Products to spread the word of our...

    Hell Does Not Exist And you can prove it. Get the facts See for...

    Is Mormonism True? Learn the truth. You can't afford to miss it.

    Fill Church Pastor Jobs Fill Pastor Positions Faster With...

    Marriage and Eternity A New Christianity that believes

    I assume that "Satan" is the trigger word for "New Christianity"?

  • wade (unregistered)
    private static bool GetTrue() 
    {
       return (random() / (float) RAND_MAX) < 0.9; 
    }
    
  • (cs)

    Yep, that's really bad coding. It should be one of the below:

    return not GetFalse(); // ties them


    return GetRegistryValue( 'SYSTEM_CONSTANTS\Boolean\TrueValue');


    return ( 999 == 999 ); // test hardware

  • Anonymous (unregistered)

    I just tried to GetTrue() my life, but all I got was a compiler error. Something about unable to call a private method....

    I guess the truth is hidden and only available to those that successfully call GetEnlightenment().

  • traininvain (unregistered)

    There is actually a use for this. Visual Studio gives a warning about unreachable code, so if you try to comment out code with if (false) it will give a warning. Using if (!GetTrue()) doesn't get flagged.

  • tudor (unregistered)

    I don't know much about Java, but in C++ a function like this may be useful: suppose that some piece of code that you're calling takes a bool-returning callback ( bool (*callback)() ), and you want your callback to do nothing.

  • gygax (unregistered) in reply to Sad

    private static bool GetTrue() { Deity GOD("Elohim"); return GOD.rollDice(1); }

  • (cs)

    I'm voting that this code is C#. If it were Java, it would probably be called

    getTrue
    instead of
    GetTrue
    Java programmers seem to almost universally follow that convention, while .Net uses initial caps even for methods.

    Because C# has delegates, there is actually plenty of room for a function such as this as a callback function, as many people have said.

    It might be a WTF, but it might not be.

  • josh (unregistered)

    I'm surprised no one has suggested:

    bool GetTrue()
    {
      return GetTrue();
    }
  • James (unregistered) in reply to Skizz

    Nah, if it were a Scientology class, it would look like this:

    private static bool GetTrue(){
       if(user.isMedia() || !user.isScientologist()){
          slander(user);
          throw new LawSuit(user, ONE_BAJILLION_DOLLARS);
       }
       else{
          if(user.bankAccount().withdrawFunds(10000) == FAIL){
             excommunicate(user);
             slander(user);
             slander(user);
             slander(user);
             return false;
          }
          else{
             return true; 
          }
    }
    
  • (cs) in reply to Calli Arcale
    Calli Arcale:
    Steve:
    I won't swear this is true since it appears in the Unix fortune program's database of jokes, silliness, and pithy quotes but it's still amusing:
    The primary purpose of the DATA statement is to give names to constants; instead of referring to pi as 3.141592653589793 at every appearance, the variable PI can be given that value with a DATA statement and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of pi change. -- FORTRAN manual for Xerox Computers

    pi is a mathematical constant and therefore will never change, but the precision of it might. So the value your program actually uses for pi may well change.

    After all, 3.14 and 3.14159 are not the same thing -- but both are legitimately used as values of pi.

    The precision of the floating point variable holding the number won't change that often either.

    It's a joke, used to ilustrate a useful concept. Get over it.

  • (cs) in reply to campkev
    campkev:
    he didn't stereotype goths as fat weirdos who worship satan.

    He stereotyped fat goth weirdos as satan worshippers. If you are going to get your panties in a bunch, at least be accurate about it.

    Personally, I like my panties in a bunch, especially while fat goth weirdos are worshipping me.

Leave a comment on “Seeking the Truth”

Log In or post as a guest

Replying to comment #:

« Return to Article