- 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'll refrain from commenting on the technique. But if you must use it, at least use a sensible parameter name, like Dummy_Parm or, if you prefer verbosity, Parameter_Not_Currently_Used.
Admin
Why not just use a different name for the method, you know, put a number after it, or add a word that describes what is done differently?
Non-WTF technique:
public void sort(String[] strs);
public void sort2(String[] strs);
public void sortQuicksort(String[] strs);
WTF technique:
public void sort(String[] strs, int DO_NOT_USE_EVAR);
public void sort(String[] strs, int DO_NOT_USE_EVAR, int FIRST);
public void sort(String[] strs, int DO_NOT_USE_EVAR, int PAULA, int BRILLANT);
Why is that any better?
Admin
No no... don't specify a parameter name AT ALL. At least this seems to be common usage, and it make sense on several levels. First, you avoid the issue of coming up with a name like Dummy or something. Second, since it's not named, you can't accidentally use it (which is probably undefined behavior in C++). Third, giving it a name will cause the compiler to emit unused parameter warnings.
If you want to mark the header somehow, you can use operator++(int /unused/). It'll "never" show up under intellisense because the whole purpose of overloading operators in the first place is so you can say itr++, which won't trigger it.
To the original poster, C++ using the dummy substantially different than adding an additional parameter to a function that's written, even if you think the first is a braindead way to denote the postfix operator. The first is a language choice which is the responsibility of Bjarne Stroustrup, while the latter is an implementation detail which is the responsibility of the programmer. If you're programming in C++ and want to overload postfix ++, there's no alternative other than to use the parameter, so doing so can hardly be seen as a poor choice (unless overloading it in the first place is misguided).
Second, and more importantly, they're doing two entirely different things. The poster you were replying to said that the pathological use of that parameter is to combine two operations that very well should be in different functions into one: foo(int NotUsedExceptInOnePlace){ if(NUEOP) DosomethingSpecific() }. The purpose of the extra parameter in C++ is to distinguish two operations that SHOULD usually be separate. The analogy to the dummy parameter here would be if to overload ++ you did both prefix and postfix in one function that took one parameter that told you which was the case.
In short, the C++ instance is mostly a matter of notation -- how do you mark whether you do prefix or postfix. Adding the extra switch parameter very well may be an indication of a design flaw in the implementation. Regardless of what you think of the notation Stroustrup chose, IMO it's in a noticibly lesser degree of fault than the latter.
Admin
Hmm, I don't know about C# or C++, but if this was Java, I would assume that the methods themselves would be implemented like this:
<font face="Courier New"><font size="2">public object LoadOrg(int cmpKey, object DO_NOT_USE_AT_ALL_EVER) {
return LoadOrg(cmpKey);
}
</font></font><font face="Courier New"><font size="2">public object LoadOrg(int cmpKey) {
// Real code here
}
public void SaveOrg(int cmpKey, object org, object DO_NOT_USE_AT_ALL_EVER) {
return SaveOrg(cmpKey, org);
}
</font>
</font><font face="Courier New"><font size="2">public void SaveOrg(int cmpKey, object org) {
// Real code here
}
</font> </font>
Admin
I don't seem what is all the fuss. It's not like the code is going to affect any of us. I don't think he meant any harm. It could be that he is just short of charm. Or maybe the programmer has a gift of rhyme. Steve, is this code used anytime? I am sure there are bigger WTFs ahead, but if there are our careers will be dead. <FONT face="Courier New" size=2>DO_NOT_USE_AT_ALL_EVER_I_MEAN_IT. Does anyone want a peanut?</FONT>
<FONT face="Courier New" size=2></FONT>
<FONT face="Courier New" size=2>captcha = poprocks</FONT>
Admin
Hello, my name is Inigo Montoya, you quoted my parent, prepare to cry.
Admin
Ah, yes, I should have known not to post and then not check back over the weekend. The sexist police would catch me without me having a chance to defend myself. Well done. You totally caught me. I suppose I could have just said coworker and then you would have assumed I was referring to a male coworker until the second sentence when I used the pronoun "she." And perhaps that would have offended you too? "How dare you refer to a woman coworker as "she!!!" Give me a break. I have worked with multiple incompetent male coworkers as well. I was just saying female to differentiate, because as I already stated, when you just say coworker in the IT realm, it is assumed male. I was just trying to save you geniuses a bit of thinking.
Admin
Yes, yes, I must be a real sexistic pig, but this IS funny :)
Admin
I'd be more worried about people being inside the reactor than pushing that button.
Admin
What about:
Admin
hahahahahahahahahahahaa
OMFG This stuff never ceases to amaze me.
How about
Public object IdontThinkThisFunctionisGoingToWork(int TheKey, object ImNotSureWhatThisParameterIsDoing)
Admin
<FONT face=Verdana>Isn't it obvious? The parameter expects an array of 6 bytes set to the exact values of {4, 8, 15, 16, 23, 42} and they must be passed in every 108 minutes. Nobody needs to know what happens if anything other than that is passed into the routine.</FONT>
Admin
I need to move to Australia!
Admin