- 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 see the truth - this is for those tribool cases where File-Not-Found just won't do!
Admin
Better yet:
private static bool GetTrue() { return false; }
I leave the third alternative an exercise to the reader.
Admin
Truly enlightening.
Admin
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 ^.-
Admin
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
Admin
Admin
// // You can't handle the truth :) // private static bool GetTrue() { System.exit(1); }
Admin
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.
Admin
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";
(...)
Admin
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
Admin
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.
Admin
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.
Admin
Admin
Spoken like a true fat weirdo who worships satan :P
Admin
Alas, the truth is out of scope for me. Forsooth! 'Tis declared private!
Admin
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(); }
Admin
private static bool GetTrue() { return File_Not_Found; }
Admin
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).
Admin
It must be a Scientology class as the truth is private and only accessable to members or friends.
Admin
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
Admin
Failure to read the article before calling "hate crime" = worse than failure.
The article reads:
Whereas you seem to have read:These two statements are not the same.
Admin
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.
Admin
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.
Admin
Whoever wrote that was likely passing those character constants to a function that didn't take const arguments because "const is too hard."
Admin
So...
You are into goth
Admin
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); } }
Admin
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.
Admin
I had some theories about how this could be useful function, but they all vanished when I read again the declaration "private static"
Admin
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:
Admin
private static String IsReadyForEnligthment(String sName) {
if (getTruth()) Return sName + "is ready for enligthment"; else return "PEACHES!!!" }
Admin
Admin
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.
Admin
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:
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...)
Admin
And, of course, we're getting Google ads about the Song of Solomon.
Admin
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
Admin
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:
Admin
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();
Admin
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.
Admin
We are? Maybe you are, but I'm not:
I assume that "Satan" is the trigger word for "New Christianity"?
Admin
Admin
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
Admin
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().
Admin
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.
Admin
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.
Admin
private static bool GetTrue() { Deity GOD("Elohim"); return GOD.rollDice(1); }
Admin
I'm voting that this code is C#. If it were Java, it would probably be called
instead of 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.
Admin
I'm surprised no one has suggested:
Admin
Nah, if it were a Scientology class, it would look like this:
Admin
It's a joke, used to ilustrate a useful concept. Get over it.
Admin
Personally, I like my panties in a bunch, especially while fat goth weirdos are worshipping me.