Comment On Convoluted toString, Interesting Comments, and More

"Everyone knows that Russians are the best programmers, and the guy we recently hired is no exception," Kip DeMane wrote, "though his English is a little... off. Here are his comments from a recent commit." [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: Convoluted toString, Interesting Comments, and More

2010-05-20 02:44 • by SlyEcho
If it was Javascript I would write it:

googleId = googleId || null;
It ensures googleId is null if it was undefined, null or '' previously. Of course if the intended use for the null value was something like this later:

if (googleId != null) { ... }
Then the first line is not needed as you can just simply write:

if (googleId) { ... }

Re: Convoluted toString, Interesting Comments, and More

2010-05-20 04:22 • by SenTree
googleId = googleId == null ? null : googleId; // ensure really null
You have to be really certain that googleId is really null, otherwise it might override googleSuperego.

Monsters from the googleId might then destroy the 'Don't be evil' mantra.

Re: Convoluted toString, Interesting Comments, and More

2010-05-20 04:22 • by Laser-Opto the Supervillain (unregistered)
goggleEyed = goggleEyed == null ? null : goggleEyed; // ensure really dull

FTFY

Re: Convoluted toString, Interesting Comments, and More

2010-05-20 05:27 • by TbK (unregistered)
I am new to tdwtf, but I like it.

Just wanted to mention that most of this horrible code in this issue is optimized by the compiler anyway, isn't it?

Re: Convoluted toString, Interesting Comments, and More

2010-05-20 06:37 • by Pot-ah-to Pot-ay-to (unregistered)
309159 in reply to 309156
TbK:
I am new to tdwtf, but I like it.

Just wanted to mention that most of this horrible code in this issue is optimized by the compiler anyway, isn't it?


Nope. Most of it just blows up in the user's face.

Re: Convoluted toString, Interesting Comments, and More

2010-05-20 08:02 • by Andrew in a Suit (unregistered)
309161 in reply to 309044
"The sad part about this code," Ramin writes," is that its author actually tries to justify this pattern. "

googleId = googleId == null ? null : googleId; // ensure really null


The sad part about some broken VMs I can name, possibly still including PHP, is that the pattern is justifiable.

Re: Convoluted toString, Interesting Comments, and More

2010-05-20 12:03 • by Harrow (unregistered)
cAMELtOEvARS
cONSISTENTcODEfORMATTING
eTC.

-hARROW.

Re: Convoluted toString, Interesting Comments, and More

2010-05-20 16:54 • by AHB (unregistered)
This reminds me of a CS professor I had in college. He was from Germany and had a thick accent. His grammar was understandable, but sometimes hilarious.

One day he was giving a lecture on probability:

"OK, say we flip ze coin. Now, say I want head." I smile at one of my classmates. A few minutes later "OK, so all I want is head." Now I snicker a little and I'm having trouble not laughing. I look around at the rest of the 19 year olds in the classroom and the situation is dire, everyone is about to bust out laughing. After he says a couple more variations of "All I want is head" he realizes that something's up and next time it's, "so now all I want is tail" and everybody's laughing out loud.

Another time he was talking about dynamic programming and the problem of loading packages of different sizes into a truck. He's trying to call the algorithm the packer but it comes out as pecker. He brought the house down once he started talking about using recursion, asking his "little brother" to do some of the work for him: "SO now I'm going to use my little brother's pecker..."

Re: Convoluted toString, Interesting Comments, and More

2010-05-20 22:17 • by Eternal Density
309245 in reply to 309045
djmaze:

public static bool IsInfiniteLoop()
{
return !IsFiniteLoop();
}

public static bool IsFiniteLoop()
{
return !IsInfiniteLoop();
}

void definiteCrash()
{
IsInfiniteLoop();
}
Hmm, how about this?
public static bool IsInfiniteLoop()

{
try
{
return !IsFiniteLoop();
}
catch (StackOverflowException)
{
return true;
}
}

public static bool IsFiniteLoop()
{
try
{
return !IsInfiniteLoop();
}
catch (StackOverflowException)
{
return !true;
}
}

Re: Convoluted toString, Interesting Comments, and More

2010-05-21 02:08 • by iMalc (unregistered)
Camel Case is great until you start writing methods with names such as the clbuttic:
bool PenIsUp() { return !PenIsDown(); }
bool PenIsDown() { return !PenIsUp(); }

GoogleID

2010-05-21 05:12 • by Anonymous (unregistered)
Anyone who can't see what the GoogleID comment is doing needs to brush up on some modern languages. I could immediately determine the intention of that code and why it was doing what it was doing.

Like it or not, loose comparison is becoming extremely common thanks to languages like PHP and javascript. Yes, the real WTF may be the language itself, and it may be stupid, but that doesn't change the fact that many modern languages are heading that direction and you need to at least be able to interpret code that way in your head when necessary, or start preparing for retirement.

Re: Convoluted toString, Interesting Comments, and More

2010-05-21 07:14 • by methinks (unregistered)
As usual, the "Real WTF" (TM) lies in the comments:

Most commenters obviously did not get that

1) "Camel toe" is a mix-up with "camel case", a naming convention for source code identifiers, in which adjacent words in otherwise completely lowercase names start with a capital letter to increase readability:
thisIsACamelCasedIdentifier
"Camel case" thus pertains to the "humps" inside such names.

2) "Camel toe" is something completely different and quite a well known meme on "teh internets":
http://www.urbandictionary.com/define.php?term=camel+toe

The russian guy was obviously thinking about something else when writing this ;o)

Remember, the internet is for p0rn! ;o)
http://www.youtube.com/watch?v=T-TA57L0kuc

Re: Convoluted toString, Interesting Comments, and More

2010-05-21 09:25 • by jerk_programmer (unregistered)
309280 in reply to 309057
DES:
FeepingCreature:
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.


No, it will never make sense. What it actually does is:

googleId = googleId

Incorrect.

Perl:
http://stackoverflow.com/questions/137487/null-vs-false-vs-0
Javascript:
http://www.bloggingdeveloper.com/post/JavaScript-null-vs-undefined-The-Difference-between-null-and-undefined.aspx

and so on, it is very common in dynamically typed languages that 2 values may be equal under == but have different types and be not equal under some other operator such as ===

Re: Convoluted toString, Interesting Comments, and More

2010-05-21 09:27 • by wulf (unregistered)
309282 in reply to 309055
sink:
((Object)this).toString executes the implementation of Object instead of extented class. Like in super.super....toString().



No. It doesn't matter what super or interface type you choose to "view" an object as, it matters what specific type the object actually is. That's the whole point, really. Your way would make inheritance completely useless.

Re: Convoluted toString, Interesting Comments, and More

2010-05-21 11:38 • by sink (unregistered)
309334 in reply to 309282
Right! I turned crazy by trying to force sanity into that code.

Re: Convoluted toString, Interesting Comments, and More

2010-05-21 11:39 • by sink (unregistered)
309336 in reply to 309282
wulf:
sink:
((Object)this).toString executes the implementation of Object instead of extented class. Like in super.super....toString().



No. It doesn't matter what super or interface type you choose to "view" an object as, it matters what specific type the object actually is. That's the whole point, really. Your way would make inheritance completely useless.


Right! I turned crazy by trying to force sanity into that code

Re: Convoluted toString, Interesting Comments, and More

2010-05-24 09:02 • by nothanks (unregistered)
309418 in reply to 309260
methinks:
As usual, the "Real WTF" (TM) lies in the comments:

Most commenters obviously did not get that
[...]

Whoosh!

Re: Convoluted toString, Interesting Comments, and More

2010-05-26 10:20 • by the_joke_explained (unregistered)
http://en.wikipedia.org/wiki/Cameltoe

Re: Convoluted toString, Interesting Comments, and More

2010-05-31 07:27 • by MSCW (unregistered)
310029 in reply to 309069
IronMensan:


I've defined += on container classes and I've defined == on a few classes


That doesn't mean that your operators makes sense just because you defined them.
Who are you, after all, russian coder?

Re: Convoluted toString, Interesting Comments, and More

2010-05-31 07:28 • by MSCW (unregistered)
310030 in reply to 309074
bl@h:
Since when are camels native to Russia?


Since 1917 when we conquered Asia steppes

Re: Convoluted toString, Interesting Comments, and More

2010-06-08 04:32 • by WWWWolf
VB6?

Birds?

::evil swamplike flashbacks::

Re: Convoluted toString, Interesting Comments, and More

2010-06-08 11:49 • by zx (unregistered)
a question to native speakers: how would you rewrite the Russian guy's comment in a proper way?

Re: Convoluted toString, Interesting Comments, and More

2011-11-07 05:45 • by apoc9 (unregistered)
365847 in reply to 309055
No, It doesn't.

super.toString() // call method toString defined in parent class of this instance
((Object) this).toString() // this is Object & call method toString on this instance
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment