- 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 don't get this. It's been fartillion posts about goggles doing nothing. Where is the joke hidden?
Hypocritically,
Some Random Guy
Admin
This is a particularly elegant way of setting expectedBits to 8.
Admin
Admin
It's a reference to a crappy children's cartoon called Futurama.
Admin
UP goggles
Wikipedia article on Rainier Wolfcastle, the original author of the quote (see the end of the article)
Admin
wrong! Its the simpsons. But I guess we already know that, the last guy beat me to it. Curse this bloody forum software!
Admin
Hey, now ... using that piece of code in an interview is a great idea. I might just do that if I ever interview anyone again.
I think this wtf of mine was the result of some refactoring I had to do a while ago, so at least it didn't show up right away - I think I was actually adding the "something else" role (names changed to protect proprietary information, of course), and this one just slipped by me.
The sad part is that it sat there and escaped my attention for literally months, all the while I was wondering why the data that was supposed be sent out in the rest of the function wasn't going out. And you're right, whoever said the thing about the overloaded operators ... if these had been ints instead of std::strings, the compiler probably would have warned me at least.
Oh well ... If we can't wtf ourselves, who can we wtf?
By the way, hi everyone - I'm new. ;) Is there an official introductions thread somewhere? I and my very talented co-workers spent most of the day yesterday ROFL-ing over this site - very nice!
--
Bill C
Admin
That is TOO good, I laughed till it hurt!
This is great!
Admin
Without any coupling we have NOTHING, everything has coupling at some level, there are some forms of coupling that are detrimental to the future maintenance of a system.
You might try raising an event to let the client know that things are changing since you are modifying state with a property.
Admin
even without operator overloading, reading a variable may well be cheaper than writing. Think MP systems, and what it takes to acquire a cache line for write (e.g., potentially invalidating other CPUs' copies) vs. acquiring it for read (in which case multiple processors may share the line).
I've seen the "if (foo != bar) { foo = bar; }" idiom used more than once, intentionally, for this purpose.
Admin
Futurama is neither crappy nor a children's cartoon. It's brilliant comedic gold.
Admin
Strict equality and FP numbers don't mix. Usually.
The rest is just icing on the cake...
Admin
thanks for affording me the opportunity to mentione my favorite Futurama quote (as others have mentioned, the goggles bit is from The Simpsons, also not crappy and not for children.)
"Dear Lord, that's over 150 atmospheres of pressure!"
"How may atmospheres can the ship withstand, professor?"
"Well, it's a space ship. So anywhere between 0 and 1"
Admin
Ah, Matt Groening, comic genius.
Admin
How about:
public static virtual const void Goggles() const
{
return false;
// TODO: implement this
}
/* later... */
if (Goggles())
return;
this.eyes.ApplyAcid();
Admin
Momentary lack of common sense? Some of those are profoundly moronic, and well deserving of a WTF.
Admin
Err... OK. What's the secret with the forum software then?
Admin
Isn't the first one an implementation of my "favourite" coding pattern:
"Use only one return statement within a funtion body." ;-)
Admin
It's a highly magical entity with the goals of taking over the earth and provoking mass suicides of users via the careful but random mangling of their posts.
Admin
Always click the "HTML" tag on the editor
Admin
As an interesting side note: x == x will NOT always evaluate to true in nqc if you pass a sensor as a const reference, since the sensor gets polled every time the variable in the inlined function gets accessed. So something that would look like a WTF, isn't.
Admin
An example of where write operations might be expensive and where there might be different code paths independent of this loop is if there is some type of logging or journaling of the variable changes going on. If, for example, this snippit of code were part of some type of population genetics model or weather model, that index could refer to an interation of code that gets logged and cross referenced with a time stamp and/or some other information. Put another way, there are time dependent population modeling problems where it's useful (if not required) to have a record of not just if, but also when variables change. currIndex could be defined at the beginning of the program to always write to a logfile on disk (e.g. making it very expensive). At some later date in time, that logfile might be the basis for a new run of the model inside the searchspace of the problem domain (and a different code path taken).
Of course, population models and weather simulations might have been the last thing on this guy's mind when coding that snippet up. But you never know.
Admin
I have more success with the opposite...
Admin
Especially if the "something" in question is a stripper
Admin
.
.NET is a particularly poor example of this.
Mostly because .NET is not a language.
Admin
Hmm...maybe nextIndex and currIndex are objects that are cheap to test for non-equality but expensive to assign???
Admin
Actually, that's just a WTF of the language. Stuff like that (ie sensor polls) should be returned by a function call, not by a variable. With function return values, x() == x() is obviously not always true (consider rand() == rand()). So obviously, whoever designed nqc should have made it a function, but instead made it a WTF! (And yes, I know someone is dying to bring up the infamous 'volatile' keyword. Grrr.)
Admin
That's awsome... it will probably work in 20 years. By then though programming would probably look like this:
f = 5m+4z-2x^2+6u^5
g = f '
d = g / 6m
Don't even ask what that is... just made up algebraic crap with a derivitive thrown in for fun. Maybe it would calculate the video or something...
Admin
if that is the case, not only should the Dev be taken out and shot for something so obscure as that, but also MS, for giving the Dev that weapon of mass distraction in the first place...
Admin
All of this reminds me of the system that we recently re-built from scratch. It was littered with things like
And the
method was this:Damn, I hated that system....
Admin
I reacted to this too when I heard about it in C#. I guess IDEs can help you with it, but still. I think I'll stay with Java. I like strict exception handling too. Not everyones cup of tea, I know.
Admin
I agree, this is not a WTF.
Checking a variable before setting a property (C#, Delphi) is sometimes a must, especially when OOP "enthusiasts" pack their property setter methods with computation-extensive logic.
Admin
Yes, it's possible. And if it were true, that would be a HUGE WTF. I can't think of a single situation where a [decent] C# programmer would want to write a property that would change its own return value just by being accessed.
Admin
Admin
*sigh*
Yes, it's possible. And if it were true, that would be a HUGE WTF. I can't think of a single situation where a (decent) C# programmer would want to write a property that would change its own return value just by being accessed.
Admin
Here's one....
Suppose you were implementing a Lazy load pattern, so that the object is not actually populated until a property is accessed....
In any case it wouldn't explain this
Most likely there used to be some more code there that got deleted and not cleaned up.
Admin
At the risk of defending this, there was probably more code originally, so that retVal might have already been set when it got to the if statement.
Admin
How about you're in a nice observer pattern where changing a value will notify all observing objects of the change? that could really cascade into a big cpu-suckup everytime a user presses 'save' without changing anything to this variable. Is using a GoF pattern also coupling? At some point it might be interesting to know whether a variable has changed (think changelogging, think observing stuff, think whatever you can imagine), and isn't the setter of that variable the best possible position to do so? Or do you want code concerning the change of a single variable scattered around all your project? Doesn't seem very maintainable to me.
Admin
Indeed. The elegance is that they used the pleasingly simple "BitCount", where they could have used a random much more complicated expression. As long as the result can be legally compared to an int in whatever language this is, you can replace it with anything without side effects, and it won't make a difference.
Admin
<FONT face=Verdana color=#000000 size=2>solved the connectionOpen || !connectionOpen mistery [H]
public bool connectionOpen
{
get{return _connectionOpen = !_connectionOpen;}
}</FONT>
Admin
I didn't have time to read other responses but, some of these could be used for debugging purposes where the debugger's performance to check conditional breakpoints is so slow that it's much faster to write a conditional statement and do self assignment to break at a particular point upon certain conditions.
Regardless, the comments are yeah, very misleading if that was the original intent.
Admin
float checkAmt is obviously the biggest WTF of them all.
Admin
We really just need to make a function for that joke so it doesn't get reinvented in each thread.
Admin
Nothing really wrong with that. What if the logic for validating a check amount changes in the future? They'll be glad they separated the validation logic when they're making a change to one function instead of a whole ton of statements that could be tough to track down.
Admin
sadly there is no logic in this code, because it is equal to
Admin
Well, with the introduction of operator overloading some decades ago, really.
Admin
I'm surprised no one came up with this to match the WTF:
if (goggles || !goggles) burn_eyes();
Admin
I've actually seen this a lot with database connections. In addition Open and Closed there is also Connecting, Broken, and a couple of others. Not opened, not closed.
Still not exactly a great way to handle it though.
Admin
"Then there's William, who's coworker always insisted..."
It's always fun reading a post that makes fun of someone else's syntax and logic, yet can't be bothered to write syntactically correct sentences.
Admin
Assignment is expensive, there is no point doing an assignment statement unless you need to.