Comment On Seeking the Truth

We're all seeking truth and elightenment. Some find it in Christ, some in Allah, some in Shiva, crazy celebrities in Xenu, fat goth weirdos in Satan, or the truly enlightened who've been touched by the Flying Spaghetti Monster's Noodly Appendage. Others find it in science. Maybe even in love. Well, for those of you that haven't found the truth yet, here it is: [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: Seeking the Truth

2007-05-14 10:35 • by snoofle (unregistered)
I see the truth - this is for those tribool cases where File-Not-Found just won't do!

Re: Seeking the Truth

2007-05-14 10:35 • by Sad (unregistered)
Better yet:

private static bool GetTrue()
{
return false;
}

I leave the third alternative an exercise to the reader.

Re: Seeking the Truth

2007-05-14 10:36 • by gygax (unregistered)
Truly enlightening.

Re: Seeking the Truth

2007-05-14 10:36 • by 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 ^.-

Re: Seeking the Truth

2007-05-14 10:37 • by 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

Re: Seeking the Truth

2007-05-14 10:38 • by Sad (unregistered)
136234 in reply to 136228
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!

Re: Seeking the Truth

2007-05-14 10:40 • by Stephen Sweeney (unregistered)
136235 in reply to 136229
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);
}

Re: Seeking the Truth

2007-05-14 10:43 • by 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.

Re: Seeking the Truth

2007-05-14 10:47 • by th0mas
136238 in reply to 136237
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";

(...)

Re: Seeking the Truth

2007-05-14 10:49 • by 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

Re: Seeking the Truth

2007-05-14 10:51 • by 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.

Re: Seeking the Truth

2007-05-14 10:52 • by akatherder
136241 in reply to 136237
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.

Re: Seeking the Truth

2007-05-14 10:52 • by whicker (unregistered)
136242 in reply to 136237
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.

Re: Seeking the Truth

2007-05-14 10:53 • by Dave (unregistered)
136243 in reply to 136237
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

Re: Seeking the Truth

2007-05-14 10:53 • by Spiceweasel (unregistered)
Alas, the truth is out of scope for me. Forsooth! 'Tis declared private!

Re: Seeking the Truth

2007-05-14 10:54 • by Not First (unregistered)
136245 in reply to 136235
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();
}

Re: Seeking the Truth

2007-05-14 10:58 • by Blue (unregistered)

private static bool GetTrue()
{
return File_Not_Found;
}

Re: Seeking the Truth

2007-05-14 10:59 • by DigitalLogic
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).

Re: Seeking the Truth

2007-05-14 11:03 • by Skizz (unregistered)
It must be a Scientology class as the truth is private and only accessable to members or friends.

Re: Seeking the Truth

2007-05-14 11:04 • by 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

Re: Seeking the Truth

2007-05-14 11:07 • by misha
136251 in reply to 136237
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.

Re: Seeking the Truth

2007-05-14 11:12 • by clevershark
136252 in reply to 136237
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.

Re: Seeking the Truth

2007-05-14 11:14 • by livid
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.

Re: Seeking the Truth

2007-05-14 11:16 • by Derrick Pallas
136254 in reply to 136238
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."

Re: Seeking the Truth

2007-05-14 11:20 • by Harsh
136255 in reply to 136237
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

Re: Seeking the Truth

2007-05-14 11:21 • by 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);
}
}

Re: Seeking the Truth

2007-05-14 11:24 • by 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.

Re: Seeking the Truth

2007-05-14 11:25 • by qbolec
I had some theories about how this could be useful function, but they all vanished when I read again the declaration "private static"

Re: Seeking the Truth

2007-05-14 11:31 • by 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

Re: Seeking the Truth

2007-05-14 11:34 • by JF (unregistered)
private static String IsReadyForEnligthment(String sName) {

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

Re: Seeking the Truth

2007-05-14 11:35 • by RayMarron
136262 in reply to 136249
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!

Re: Seeking the Truth

2007-05-14 11:37 • by Calli Arcale (unregistered)
136263 in reply to 136259
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.

Re: Seeking the Truth

2007-05-14 11:41 • by Zygo (unregistered)
136264 in reply to 136253
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...)

Re: Seeking the Truth

2007-05-14 11:43 • by Jojosh_the_Pi
And, of course, we're getting Google ads about the Song of Solomon.

Re: Seeking the Truth

2007-05-14 11:54 • by seejay
136268 in reply to 136261
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

Re: Seeking the Truth

2007-05-14 11:57 • by Zygo (unregistered)
136269 in reply to 136257
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.

Re: Seeking the Truth

2007-05-14 11:57 • by 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();

Re: Seeking the Truth

2007-05-14 12:01 • by 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.

Re: Seeking the Truth

2007-05-14 12:01 • by Zygo (unregistered)
136272 in reply to 136265
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"?

Re: Seeking the Truth

2007-05-14 12:03 • by wade (unregistered)

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

Re: Seeking the Truth

2007-05-14 12:05 • by Ancient_Hacker
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

Re: Seeking the Truth

2007-05-14 12:17 • by 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().


Re: Seeking the Truth

2007-05-14 12:21 • by 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.

Re: Seeking the Truth

2007-05-14 12:30 • by 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.

Re: Seeking the Truth

2007-05-14 12:31 • by gygax (unregistered)
136281 in reply to 136229
private static bool GetTrue()
{
Deity GOD("Elohim");
return GOD.rollDice(1);
}

Re: Seeking the Truth

2007-05-14 12:51 • by EvanED
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.

Re: Seeking the Truth

2007-05-14 13:10 • by josh (unregistered)
I'm surprised no one has suggested:

bool GetTrue()

{
return GetTrue();
}

Re: Seeking the Truth

2007-05-14 13:16 • by James (unregistered)
136292 in reply to 136249
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;
}
}

Re: Seeking the Truth

2007-05-14 13:32 • by Mcoder
136293 in reply to 136263
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.

Re: Seeking the Truth

2007-05-14 13:48 • by MyWillysWonka
136296 in reply to 136240
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.
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment