- 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 can see how this would happen... some js frameworks require callback functions; the developer probably simply wasn't aware of anonymous functions.
Admin
BRILLANT!
Admin
See the code for /bin/true included with Solaris. http://forums.worsethanfailure.com/forums/thread/90649.aspx
Or IEFBR14 which sometimes fails at doing nothing
Admin
Self-documenting code. A blank line without code before a semicolon is often suspect as something that got accidentally deleted or accidentally prematurely terminates an if statement (the classic "oops I put a semicolon after the if line"). Using a dummy function that explicitly shows you are intending to do nothing creates no overhead and makes your code more readable and easier to debug.
Admin
A function named "DoNothing" is very Dilber-esque!
Admin
You're the WTF today that's a design pattern moron
Admin
A good compiler will surely optimize it...
Admin
A very Zen observation.
"There once was a master programmer who wrote unstructured programs. A novice programmer, seeking to imitate him, also began to write unstructured programs. When the novice asked the master to evaluate his progress, the master criticized him for writing unstructured programs, saying, ``What is appropriate for the master is not appropriate for the novice. You must understand the Tao before transcending structure.''" - Tao of Programming
Admin
function DoNothing() { var x = 1; for(var i=0; i<1000; i++) { x *= i; } return; }
function Nothing() { var i=4; while(i > 7) DoNothing(); }
Admin
Been somewhere there not long ago.
There was somefunction(callback) and I wanted no callback. So I recalled there already IS a 'nothing' function called 'void', and so happily wrote somefunction(void(null)); And it took me more than half a hour to recall you need to pass the reference and it's the (null) that breaks my code.
Admin
Admin
It actually makes sense to declare an empty function (though perhaps it wasn't the code authors intention). It's useful when you need to pass callback handlers to function, for example:
Admin
Since a function in JavaScript is also an object, Nothing not only DOES nothing, it IS nothing ;-)
Admin
Not enterprisey enough. If this were Java, it would need more XML. To be, uh, more interoperable or something.
Admin
function NoQuack() { }
Admin
Shouldn't DoAnything() be something like: DoAnything() { *() Function; Function = ( *() )Random(); *Function(); }
(Or however that should be written)?
(In case my intent is unclear, Create a pointer to a function, Fill it with random number, and then attempt to execute it. Of course, the possibility that it would do anything other than sig 11 is very low.....)
Admin
Or....
function(){} as the callback?
Or....
function DoNothing() { Do(Nothing); } function Do(f) { f(); } function Nothing() {}
Admin
Boo! Not enterprisey at all!
THIS is how you do is:
Admin
In Soviet Russia nothing do you.
Admin
As advertised.
Admin
In addition, in almost any OO language there are going to be times when you have to give an empty body to the implementation of a method. For example I recently implemented a little state engine in which the states implemented an interface containing a moveToNextState() method. For the end-states the method does nothing (but at least has a comment explaining why).
Of course the real wtf is that I'm writing this instead of doing real work.
Admin
That loop isn't infinite. At some point when DoNothing() is called, i will be 42 at which time it'll call Nothing() and i will be 41... However, at that point DoNothing() is not called again and the game is over...
Why do we need functions that DoNothing anyway, when we have so many managers doing a great job at that already!
(I had to add (...) between [ /code ] and [ /quote ] or my first line of comment would have been part of his quote ???)
Admin
I thibnk we're missing one function that's somewhere in darker parts of the code:
Do(noThing) { if(!noThing) DoNothing() else Nothing() }
Nothing() { DoNothing() ; }
DoNothing() { Do(Nothing) ; }
Admin
Maybe someone didn't know how to implement a nice delay.
// pseudo as hell, also unsafe function Wait(seconds) { SetTimeout(seconds, "Nothing();") }
Admin
... and when I think that people are laughing about VB or Coldfusion. Of course, you can write a function that does nothing
private sub DoNothing: end sub
But, for sure, you don't need such WTFs just to make compilers happy
CAPTCHA: quake (Shoot'em up, those people who create (so-called modern) programming languages)
Admin
DoNothing() is clearly ambiguous, it can be intepreted in two different ways.
So when you look it like this, you can do nothing by not doing anything or actually doing nothing. Both will do the same thing (which is nothing) as long as Nothing() is not something.
I think Jerry Seinfeld wrote these functions just to annoy people.
Admin
Now if you'll excuse me, I need to take something to cure me of the pain of writing code with its head that far up its enterprise...
Admin
At least it wasn't:
[code] DoNothing() { }
Nothing() { DoNothing(); }
Admin
At least it wasn't:
Admin
Somebody needs to get laid
Admin
public class ThreeMonkeys {
public void seeNoEvil(){} public void hearNoEvil(){} public void speakNoEvil(){}
}
Admin
For clean code you'd probably wish to use: click
When onclick gets false it won't follow the URL, and if JavaScript is turned off it will.
Admin
The latter is obviously for: do{Nothing();} while(...)
Admin
function Nothing() {
}
function Do(f) { f(); }
function DoNothing() { Do(Nothing); }
Admin
function Goggles() { DoNothing(); }
Admin
Admin
javascript doesn't know functionpointers - does it?
Else you could test:
if (&doNothing() == &Nothing ()) // ... why should we do so? // for the pure enlightment.
Syntax is probably wrong - when did I do C/C++ the last time? cuptchu: bathe
Admin
/**
class DoNothingTest implements TestCase {
tearUp(){
}
tearDown(){
}
testDoNothing(){ assert(ReflectionTools.getCode(NothingTools, "doNothing")); }
}
Admin
/**
class DoNothingTest implements TestCase {
tearUp(){
}
tearDown(){
}
testDoNothing(){ assert(ReflectionTools.getCode(NothingTools, "doNothing").size() == 0); }
}
Admin
DoNothing is misnamed. It very definitely does something. It returns. A REAL DoNothing would do ABSOLUTELY nothing. The processor would simply cease executing the thread, without changing any memory locations or registers. I am aware that may be impossible.
Maybe DoNothing should even halt all electron motions in the computer. Including those which cause DRAM to lose its contents if not regularly refreshed.
So essentially, DoNothing should stop time for the computer system. And somehow do so without doing anything.
Admin
If this ludicrous state of affairs isn't a WTF, I'd like to know what would be.
(Mind you, I can understand incompetent monkeys who probably shouldn't be using computers at all having trouble with anonymous functions. It's the people who beg you not to use 'with' blocks because they're "too complicated" that depress me.)
Admin
Empty functions are useful for writing viruses on c/++
Admin
From NetBSD's pkgsrc:
Admin
Hmmm, that HTML code doesn't look good:
Why should anyone need
inside
Admin
Noting() is for debug breakpoint.
Admin
Admin
Please, fix! It doesnt work!!
Chrome gives me "RangeError: Maximum call stack size exceeded" when running this:
function DoNothing(){ Nothing(); }
function Nothing(){ DoNothing(); }
Nothing();
How do i make sure it does nothing??
Admin
Checkmate for prototypical inheritance.