- 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
stories about Russians? this would be good as an audio reading...
just saying..
Admin
After a day off, Alex lets loose with an explosion of WTF. Well played sir.
Admin
I suppose all the code samples could be read in a Russian accent.
Admin
Dammit, now I have to go back through all my unit tests and check for really null. And then change my var names to camel toe.
Admin
Admin
Admin
The googleId one might make sense if the language supports overloading == and googleId is an object defined to sometimes return true on equality to null.
Admin
The toString() snippet is an even more direct example of an infinite loop.
Admin
Then it would still be a WTF for using operator overloading when it doesn't make sense (which is almost always. The only places where I can see operator overloading used sensibly is in math libraries)
Admin
It would also make sense in PHP, if you want to turn "something like null" (false, 0, etc) into "really and truly is null".
Admin
frist = frist != frist ? frist : frist; // ensure really frist
Admin
A little redundant, and slightly inconsistent, but this kind of thing helps me stay insane, and therefore continue to enjoy my job:
(No, we don't normally use i as a prefix for integers, why do you ask?)
(captcha: "paratus", as in, "Paratus! Paratus! Free Paratus!")
Admin
"googleId = googleId == null ? null : googleId; // ensure really null"
I think I have a brain haemorrhage
Admin
Too lazy to verify with actual tests, but wouldn't the toString() one just get back the default toString() method if a parent class defined a custom one? Also, the googleId snippet looks valid for languages where values can be equal to null w/o acutally being null.
Admin
((Object)this).toString executes the implementation of Object instead of extented class. Like in super.super....toString().
Admin
Why does he give names to his Camel's toes?
Admin
No, it will never make sense. What it actually does is:
Admin
No. Java will always invoke the most specific implementation of a method for a given object instance. Attempting to cast an object does not change which method implementation is invoked.
Admin
recursion
re·cur·sion [ri-kur-zhuhn]
See: recursion
Admin
I like how all those changes were applied to 1 line. Wow!
Admin
No, there are certainly cases where it makes sense. Namely if it were JavaScript, which I suspect is the case. In JavaScript, undefined == null, but undefined !== null. So the line is actually equivalent to:
[pre] if (googleId === undefined) googleId = null; [/pre]
The above would have certainly have been clearer, but I strongly suspect that it was, in fact, the intent.
Admin
Admin
No, he's right. For example in PHP, with loose comparison (==), false returns true when compared to null. But when assigned to null, it'll be of type null.
So this code is entirely legit, IF the assumed conditions hold true.
See here for reference: http://www.php.net/manual/en/types.comparisons.php false, 0, an empty array and an empty string all == null.
Admin
Admin
Not if the language is javascript and googleId was undefined. It's probably still a WTF but there are differences (in javascript):
Admin
Yea, because they couldn't possibly have committed multiple resources with the same comment at the same time...
Admin
*disclamer: this comment is not meant to imply in any way that Russians are in some way incapable or undeserving of having camels. It's just... well... nevermind.
CAPTCHA: nulla - any null that hasn't yet been checked to make sure it really is null.
Admin
As another reader told, a method is always executed using the virtual pointer, whatever the object is casted to. The only exception is the method used on super.
This looks like java written by a C++ guy. And I really think java is better that C++ in this regard.
Admin
I've defined += on container classes and I've defined == on a few classes
Admin
My initial thought on the last one was that someone was trying to use a variable that should have been declared volatile. Then I looked a little more carefully and realized it was more WTF than I initially thought.
Correct me if I'm wrong, but rewriting that code to be more readable produces this functionality:
if (googleId == null) { googleId = null; } else { googleId = googleId; }
So contrary to the comment, it doesn't even ensure that googleId is null at all, as opposed to REALLY null (a comment I'd expect with a WTF line like googleId = googleId = null;)
Admin
In our Android app, we deal with a bunch of JSON parsing. Have a look at JSONObject.NULL:
http://developer.android.com/intl/de/reference/org/json/JSONObject.html#NULL
Since JsonObject.NULL.toString evaluates to "null" (even though JsonObject.NULL == null returns true), this was causing us to end up with "null" in a bunch of our views. We ended up wrapping it in a method that converts it to real null, just like this guy is doing in the last one.
Admin
Nope, not in Java.
Admin
Sorry, didn't realize this site was "Curious Perversions in Information Technology, But No Stupid Jokes Please"...
[image]Admin
Since when are camels native to Russia?
captcha:nulla -> Make sure it is really nulla!
Admin
Then he'd test for NULL, not null (which is a reserved keyword in Java, so you can't possibly refer to something else). I still find the JavaScript explanation the most likely.
Admin
I'm a consultant, and I've never, ever done a check for really null.
Now I have to go back and redo all the Java code I've written in the past 15 years. Wonderful!
Admin
void myLifeStory() { iReceiveHead = false; iReceiveTail = false;
/* ... sigh..... */ }
Admin
Sorry, I'm not convinced that it was a purposeful stupid joke...
Admin
You have not experienced Kernighan and Ritchie until you have read them in the original Russian.
Admin
public static bool IsNotNotNotEmpty(string value) { return !IsNotNotEmpty(value); }
Admin
Hmmm, yes, they rarely are... Hopefully this will help to sort it out:
"If, in reading the following pages, you are uncertain as to whether a specific statement is meant seriously or not, simply apply this rule of thumb: If the statement makes you consider filing a lawsuit, I was kidding!"
~ Dave Barry
Admin
As already pointed out, strict comparison is required in PHP.
<?php $googleId = null; var_dump($googleId); $googleId = 0; var_dump($googleId); $googleId = ($googleId === null) ? null : $googleId; var_dump($googleId); ?>Output: NULL int(0) int(0)
Admin
undefined is certainly a possible reason for this code, but he doesn't cater for it, which the comment suggests he intends to. I don't think undefined is meant to slip through the net in this code, although it does...
I think people are getting carried away on it because to make sure it's really null, most people would just do the following...
googleId = null;
No..?
Admin
Our company uses a similar variation of Hungarian Notation to name variables. I did get to have a chuckle recently at some permissions checking code (where strings are used to denote the permission type)...
Admin
Do PHP users things that two WTFs make an acceptable piece of code?
Admin
Hmmm, indeed. I wasn't kidding, but if quoting someone else helps you cover your apparently obvious stupid joke you were trying to convey, well done...
Admin
This should really be a Get not a set. What were they thinking! With a get you could go object.HideCentercontent! But with a set, it would have to be object.HideCenterContent = some value. Crazy developers, they should really know better.
Admin
Admin
Now, removing all line feeds – that would make a difference…
Admin