| « Prev | Page 1 | Page 2 | Page 3 | Next » |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:05
•
by
Josephus
(unregistered)
|
|
stories about Russians? this would be good as an audio reading...
just saying.. |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:08
•
by
Ocson
(unregistered)
|
|
After a day off, Alex lets loose with an explosion of WTF. Well played sir.
|
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:09
•
by
joeyadams
|
I suppose all the code samples could be read in a Russian accent. |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:12
•
by
@Deprecated
(unregistered)
|
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. |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:15
•
by
djmaze
|
|
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:15
•
by
frits
|
/*** REVISION: 6.9 *** |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:18
•
by
FeepingCreature
(unregistered)
|
|
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.
|
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:19
•
by
Markp
|
|
The toString() snippet is an even more direct example of an infinite loop.
|
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:22
•
by
anonymous coward
(unregistered)
|
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) |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:23
•
by
xyzzy
(unregistered)
|
|
It would also make sense in PHP, if you want to turn "something like null" (false, 0, etc) into "really and truly is null".
|
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:24
•
by
Drew
(unregistered)
|
|
frist = frist != frist ? frist : frist; // ensure really frist
|
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:24
•
by
Michael Mol
(unregistered)
|
|
A little redundant, and slightly inconsistent, but this kind of thing helps me stay insane, and therefore continue to enjoy my job:
iFoundIt = someSet.find(val); (No, we don't normally use i as a prefix for integers, why do you ask?) (captcha: "paratus", as in, "Paratus! Paratus! Free Paratus!") |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:25
•
by
DOA
|
|
"googleId = googleId == null ? null : googleId; // ensure really null"
I think I have a brain haemorrhage |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:27
•
by
Anonymouse
(unregistered)
|
|
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.
|
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:29
•
by
sink
(unregistered)
|
|
((Object)this).toString executes the implementation of Object instead of extented class. Like in super.super....toString().
|
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:29
•
by
Lee K-T
(unregistered)
|
|
Why does he give names to his Camel's toes?
|
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:31
•
by
DES
|
No, it will never make sense. What it actually does is: googleId = googleId |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:32
•
by
Anon
(unregistered)
|
|
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.
|
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:37
•
by
Severity One
|
|
recursion
re·cur·sion [ri-kur-zhuhn] See: recursion |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:38
•
by
@Deprecated
(unregistered)
|
I like how all those changes were applied to 1 line. Wow! |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:44
•
by
Kris
(unregistered)
|
|
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. |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:44
•
by
parquet
(unregistered)
|
|
<?php
$googleId = 0; var_dump($googleId); $googleId = $googleId == null ? null : $googleId; var_dump($googleId); outputs int(0) NULL *shrug*. |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:45
•
by
Core Xii
(unregistered)
|
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. |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:46
•
by
SCB
|
He forgot to add in the comment "removed all carriage returns" |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:47
•
by
blah
(unregistered)
|
Not if the language is javascript and googleId was undefined. It's probably still a WTF but there are differences (in javascript):
|
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:48
•
by
junkpile
(unregistered)
|
Yea, because they couldn't possibly have committed multiple resources with the same comment at the same time... |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:50
•
by
Sir Read-a-Lot
(unregistered)
|
Why does a Russian have a camel in the first place? *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. |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:54
•
by
Aris
(unregistered)
|
|
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. |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:57
•
by
IronMensan
(unregistered)
|
I've defined += on container classes and I've defined == on a few classes |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 09:57
•
by
Steve H.
(unregistered)
|
|
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;) |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 10:00
•
by
Jake Boxer
(unregistered)
|
|
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. |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 10:09
•
by
enfiskutensykkel
|
Nope, not in Java. |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 10:13
•
by
@Deprecated
(unregistered)
|
Sorry, didn't realize this site was "Curious Perversions in Information Technology, But No Stupid Jokes Please"...
|
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 10:17
•
by
bl@h
(unregistered)
|
|
Since when are camels native to Russia?
captcha:nulla -> Make sure it is really nulla! |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 10:18
•
by
Daniel
(unregistered)
|
|
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.
|
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 10:18
•
by
snoofle
|
|
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! |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 10:24
•
by
Whiskey, Eh?
(unregistered)
|
|
void myLifeStory()
{ iReceiveHead = false; iReceiveTail = false; /* ... sigh..... */ } |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 10:26
•
by
junkpile
(unregistered)
|
Sorry, I'm not convinced that it was a purposeful stupid joke... |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 10:26
•
by
DCRoss
|
|
You have not experienced Kernighan and Ritchie until you have read them in the original Russian.
|
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 10:29
•
by
Callin
|
|
public static bool IsNotNotNotEmpty(string value)
{ return !IsNotNotEmpty(value); } |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 10:36
•
by
@Deprecated
(unregistered)
|
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 |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 10:39
•
by
fubar
(unregistered)
|
|
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) |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 10:49
•
by
Just an ordinary code monkey
(unregistered)
|
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..? |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 10:50
•
by
ChrisB
(unregistered)
|
|
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)...
|
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 10:53
•
by
Jumble
(unregistered)
|
|
Do PHP users things that two WTFs make an acceptable piece of code?
|
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 10:54
•
by
junkpile
(unregistered)
|
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... |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 10:54
•
by
Tony
(unregistered)
|
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. |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 11:02
•
by
Quirkafleeg
(unregistered)
|
… you get a compile-time error. |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 11:07
•
by
Quirkafleeg
(unregistered)
|
That wouldn't make any difference. One line before, one line afterwards. Now, removing all line feeds – that would make a difference… |
Re: Convoluted toString, Interesting Comments, and More
2010-05-19 11:09
•
by
Henning Makholm
(unregistered)
|
public bool HideCenterContent {
|
| « Prev | Page 1 | Page 2 | Page 3 | Next » |