- 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 still don't get... the only WTF here is a Refactoring tool going mad.
You know:
private int foo; public Object bar;
-> add getters and setters for all field
public int getFoo() { return foo; }
public int setFoo(int newvalue) { int tmp = foo; foo = newvalue; return tmp; }
etc.
Now, you can imagine, it might have seen the true-literal somewhere, thought it was a variable, and added a getter function.
Admin
Yes, "pathetic humorless whiners" would have been more accurate.
Admin
I'm into goth stuff, but I skimmed right over the comment.
Frankly, I have more important things to get upset and worked up about. I've found that life is far less stressful if I don't give a damn about occasional flippant comments that have no bearing on my life.
-- Seejay
(PS: I'm not a pathetic humourless whiner either, thankfully!)
Admin
Admin
It's important to wrapper such things as, given the way the industry is going, the value or method of deciding TRUE may change in the near future.
Also, what if the "suits" someday wish all truths to instead be declared as falsities.. but only on Wednesdays? Instead of having to hunt down all 20,000 conditions of TRUE, you simply maintain the singular function with something like: if ( strcmp(today, "WED") ) { return false; } else { return true; }
With executives pushing harsher business requirements, and IT people bending to these new requirements near-daily, as well as the amount of outsourcing overseas occurring, it's important such forward thinking methodologies be employed in our everyday code.
Admin
So you think there is a SetTrue function somewhere?
Admin
captchya: "burned" - yes you are!
Admin
Admin
For the record, Xenu is not Scientology's version of God (in fact, I've yet to meet a Scientologist that even believes that story). If the story is to be believed, Xenu would be the devil.
Admin
private static bool GetTrue() { throw new ExistentialismException(); }
Admin
Better yet...
Admin
This isn't a WTF until we see the context it is used in.
There are many times when you have a system that uses delegates or function pointers for customizable functionality.
For example, imagine a job scheduler, that has a simple rule system about when it is allowed to run a job. C#:
Now later on, you can do this:
This is a perfectly valid .NET 1.1 program and there really aren't many ways to do this better.
However, if this were for .NET 2.0, I might have taken points off for not using anonymous delegates, depending on whether or not GetTrue was referenced only once or not. If GetTrue was a one-shot usage, then I would have used Anonymous delegates:
However, if the "Always run" rule is used in multiple places, then I would go back to the GetTrue function (and make the name a bit more meaningful while I was at it).
It's all about the contextamins.
Admin
private static bool GetFalse() { return InvertBool(GetTrue()); }
Admin
Given just that code excerpt it does seem redundant. Given more context however, it might not seem ridiculous. What if the programmer is implementing an interface and the semantics of getTrue() is not always consistent? For that particular class it may be pertinent to always return true. But if another class has a different meaning/purpose, then getTrue() might be returning the truth in different context. I don't consider this a true WTF unless more context is given.
Admin
It's just a testing function. If you are testing another function and want to make sure you are testing the "true" path, you would substitute this function for the boolean test. That way you are only testing one function at a time.
There are obviously better ways to do this (i.e. any other way).
Admin
The real WTF is that it might be in some weird namespace that mangles the standard definition of true, so it really should be:
[code]private static bool GetTrue () { return (bool) !!true; }
Admin
You missed one:
private static Set<bool> getTruthiness();
Admin
Exactly.
(Though this is dependent on the assumption that it is, in fact, C# and not Java, since Java doesn't have those. (At least as of my latest knowledge.))
Admin
obviously this code was orginaly doing something else, but that feature got removed,
Admin
The real WTF is that people write 50-line example code fragments to illustrate their point that getTrue() makes sense when its address is passed as the argument of a function...after several other people have written exactly the same statement, but used 25 words or less.
Admin
Like whether The Cure or My Dying Bride is "more goth"
Admin
return constantly(true);
Admin
You want enlightenment?
root@linuxbox# apt-get install enlightenment_
See? It's so simple.
Admin
In C++, string literals are arrays of const char, but there is an implicit conversion to (char *), so even in that langauge you never would have const-problems with passing string literals to functions expecting char *.
Admin
Admin
Admin
Are you trying to get sued?
Admin
Yes and no.
No, because there're two common cases: adding getters and setters, and just adding getters (and no setters).
Yes, because the setter might have actually been created. Since it would break with a compile error, the mistake was found and corrected. However, since the getTrue() is valid, this second mistake was not noticed.
BTW, I'm sure you forgot the return. Typical contracts of setter methods in Java are: don't return anything at all, return the old value. So your implicit "return false;" sure can't be intended.
Admin
Reminds me of a article about Null Object Refactoring.
http://aspalliance.com/1258_Null_Object_Refactoring
Admin
As a fat goth satanist, I'm offended that I'm being stereotyped as a weirdo.
As a fat satanist weirdo, I'm offended that I'm being stereotyped as a goth.
And perhaps most of all, as a fat goth weirdo, I'm offended that I'm being stereotyped as a satanist!
Admin
bool GetTrue() { if (true != false) return !false; else return !true; }
Admin
You can find enlightenment on Sourceforge:
http://sourceforge.net/projects/enlightenment
captcha: stinky - well, I've not had my morning shower yet
Admin
No, i disagree. Better something like
private static bool GetTrue(in bool Value) { return Value > false; }
PS: but what is it obviously WTF ? Couldn't it just be something like a stub argument to filter high-order-function (it is not since it does not taking arguments, but it could be something of a kind!) ?
For example, let's take Delphi. Its objects' properties can be published (some early kind of reflection, allowing enumerating and changing at runtime, most use is to keep object values in external resource like window declaring resource in EXE, like database, etc). And each property can be marked if it should save it's value or it should not, when the object is serialised. You can do it, you can mark the property with true (do save), false (don't save) and same-object-boolean-method, that will yield true or false depending on the propertie value and the rest of object state. Remove from this scheme constants true anf false (for example for COM/CORBA functions-only interfaces) and clearly you immediately just NEED stub functions returning true and false!
So what is the WTF in this ?
Admin
Sure he did not. The proper verb he would be "wrapperized"
capthca:onomatopoeia - hope i will manage to key it in correctly...
Admin
With all the stereotypes you forgot one thing:
REAL fat goth weirdos are not upset about being called "fat" or "weirdos" but being called "goth"!
Admin
Admin
Its always such a pity when someone completely misses the wtf...sigh
Admin
I wish my lawn was an emo. Then it would cut itself!
Admin
private static bool GetTrue() { //more true than true if (true == true){ return truer; } }
Admin
Heh, now it's time for you to figure out which one of your coworkers submitted you to theDailyWTF :)
Admin
Honestly, if you are using this to comment out code, then you probably want the unreachable code detection.
If you really want the code commented, then just highlight the whole section and do ctrl+k,ctrl+c to uncomment ctrl+k,ctrl+u.
Admin
Actually, Xenu is the $cientologist's idea of Satan. But don't worry, they have him trapped behind a forcefield powered by an eternal battery or something. They find their truth in the writings of one L. Ron Hubbard, a True Nutbag if ever there was one.
P.S. You can't defame the dead, so I can call LRH a lying, thieving, con artist, asshole Satanist disciple of Aliester Crowley as much as I want :P
Admin
My favorite is this little gem from some code I am working on:
#define ELEVEN 11
Admin
i love you
Admin
Now that's fighting talk. My Dying Bride are a black metal band and The Cure are just an indie band with bad dress sense ;-)
Admin
But it's not defamation if it's true.
Admin
and so on ...
Admin
Actually, some coding style guides do recommend using functions like that instead of using constants. I do fail to see the point of this when dealing with Bools, but...
Admin
Ah, I see your problem. It should actually read
private static bool getTrue() { return true; }
P.S.: How come I could cut&paste the captcha into the text box?
Admin
Its anticipating another "Indiana PI Bill" perhaps?
http://en.wikipedia.org/wiki/Indiana_Pi_Bill