- 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
...
Admin
Admin
Admin
Admin
You're quite the party pooper. Now what do we talk about?
Admin
Brrriiliant!!
Admin
The real WTF would be if it did something.
Admin
Maybe one of them doesn't return anything, whereas the other has no side effects.
'scuse my language, I don't speak java
Admin
Maybe they forgot to define what "doing nothing" entails and intended on filling it in at a later time...say, just before production release?
I would love to see their reasoning behind making nothing functions though.
Admin
captcha: doom
Admin
Doing nothing = waiting to eventually do something
Admin
I'm not seeing the wtf here. Obviously there's a difference between nothingness and not doing anything.
Admin
This must be som sort of bug-prevention. How many times have you heard the following?
"The application crashed, you did the last check-in, what did you change?" "Nothing"
So by assuring a really harmless implementation of Nothing() such things should never occur...
Admin
DoNothing should call Nothing though:
function DoNothing{ Nothing(); }
Admin
Don't do what Donny don't does. Even if Donny Don't doesn't do anything.
Admin
Function MakeComment { }
Admin
The person who wrote Nothing() didn't realize that somebody had already written it. A simple matter of duplicate code (for a dummy callback).
Admin
Admin
Entirely not enough recursion, global variables, magic numbers, or infinite loops...
Admin
"""python version"""
Admin
doNothing() { }
dontDoNothing() { doNothing() ; }
Admin
I have only one thing to add: ""
Captcha: tesla. man, I miss my old TV
Admin
It's really just a clever deployment solution. See, who wants to go through that pesky compile step every time?
They just add calls this function and then insert code directly into it in memory at run time until it behaves as desired.
Admin
function DoNothing() { // TODO: Inline assembler does not seem to work in JavaScript :-( // TODO: Find a different way to do nothing // asm { NOP }; }
Admin
Very enterprisy.
Capta: Stinky.... ewww
Admin
Very Enterprisy
Admin
I have days that emulate this function.
Admin
http://imgs.xkcd.com/comics/exploits_of_a_mom.png
Admin
Of course, this should be:
Admin
Maybe it was written by someone who didn't know about the void operator.
Admin
Compiles Does what it says Does not have extra lines Does not need comments Does not waste nanoseconds
Etc
It's utopical
Admin
Does exactly what it says on the tin!
Admin
the second function should be named doAnything(). When you doNothing, you don't doAnything. Then it would make complete sense that doAnything() does not get called by doNothing().
Admin
Maybe some crafty API takes two callbacks, say onFail and onFailFail. This way, if the function fails you can do failure handling in onFail. If onFail fails, you call onFailFail to log an error or something.
And the API is friendly enough to yell at you for using the same function for both. Obviously if onFail fails, you don't want to call it again! Are you trying to create an infinite loop?
/Man, I'm totally going to put stuff like that n my next application just to give people a headache.
Admin
There's nothing wrong with a function called Nothing or something of the sort. I've done it more than once.
It can make it clearer what a piece of code is doing.
Admin
doAnything() { var h = Math.random(); for (var i=0; i < h; i++) { doNothing(); } }
Admin
It's javascript, not java. Your only problems are: try with no catch, and null should be lowercase. And none of the variables you're using exist, but they could be defined at any time elsewhere, so it's a runtime error only.
It never occured to me that undefined was a specific entity that could be compared to itself.
Admin
Both functions are clearly necessary to keep the code readable:
but
Really, who would want to read "do DoNothing()"?
(Hey, what about "PLEASE DO NOTHING"?)
Admin
-Harrow.
Admin
function DoNothing() { Do(); Nothing(); }
function Do() { }
function Nothing() { }
Admin
Damn- I hope that function was well tested.
Admin
I thought this looked funny. Found it in all the sites that we do.
function nothing(){ return; }
Admin
Oh cock it! You mean after all these years of avoiding JS like the plague it is, I've gone and written some for fun?!
Enter your First Name: 20 Enter your last Name: 15 Your email address is: 35@javascript_sucks.com
Admin
Empty functions are useful for overriding or specifying default event handlers in certain cases.
e.g. click
Admin
...
I wont tell anyone. My Lips are sealed. Now i have to call a friend. (Evil laughg)
Capacha: Ewww (When i will think of food that i dont like, i will think about this capacha)
Admin
Positively (well, negatively) Heideggerian!
Admin
Perhaps they think the empty function in prototype is a WTF too? http://www.prototypejs.org/api/prototype
Admin
The solution is easy: DoNothing is a function. Nothing is a constructor for instances of Nothing. So you invoke it like that:
DoNothing(); var something = new Nothing();
Admin
And while that is a joke, it's unfortunately fairly normal, as this excerpt from Sun's current implementation java.awt.Component demonstrates:
That is real, as anyone with Sun's JDK can verify by peeking in src.zip.
Admin
Presumably Nothing uses these funtions. I guess the author felt that it was good to know that they could DoNothing if they wanted to, which would be nice to know.