• Dazed (unregistered) in reply to less-than-perfect++
    Anonymous:

    Anonymous:
    <FONT face=Arial size=2>I am actually kind of surprised that no-one has suggested this usage of the method, since it is something that I see quite often when reviewing code made by less-than-perfect-programmers.

    This is clearly an example of a solution to the "overload-dilemma" that occurs when it is discovered that you need an overload to an existing method, that does more or less the same as the primary method, but in a slightly different way. This method will require the same input-parameters as well as return value, so you cannot make a clean overloaded method. Instead a bogus input variable is specified which solves the problem for the programmer ... but not necessarily for the overall application.</FONT>

    You mean like pre-increment and post-increment?

    int operator++(int& i);
    int operator++(int& i, int DO_NOT_USE_ME_AT_ALL_EVER);

    This technique is actually taught in textbooks, at least as applied to C++.

    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.

  • Shizzle (unregistered) in reply to Jesper Stocholm
    Anonymous:
    <font face="Arial" size="2">I am actually kind of surprised that no-one has suggested this usage of the method, since it is something that I see quite often when reviewing code made by less-than-perfect-programmers.

    This is clearly an example of a solution to the "overload-dilemma" that occurs when it is discovered that you need an overload to an existing method, that does more or less the same as the primary method, but in a slightly different way. This method will require the same input-parameters as well as return value, so you cannot make a clean overloaded method. Instead a bogus input variable is specified which solves the problem for the programmer ... but not necessarily for the overall application.

    Jesper Stocholm
    </font><font face="Arial" size="2">http://stocholm.dk</font>

    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?
  • (cs) in reply to Dazed
    Anonymous:
    Anonymous:

    You mean like pre-increment and post-increment?

    int operator++(int& i);
    int operator++(int& i, int DO_NOT_USE_ME_AT_ALL_EVER);

    This technique is actually taught in textbooks, at least as applied to C++.

    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.



    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.

  • (cs)

    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>

  • RobLyman (unregistered)

    Anonymous:


    if (<FONT face="Courier New" size=2>DO_NOT_USE_AT_ALL_EVER_I_MEAN_IT.equals(</FONT>DOES_ANYBODY_WANT_A_PEANUT)) {return "Oook!";}

    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>

  • (cs) in reply to RobLyman
    Anonymous:

    Anonymous:


    if (<FONT face="Courier New" size=2>DO_NOT_USE_AT_ALL_EVER_I_MEAN_IT.equals(</FONT>DOES_ANYBODY_WANT_A_PEANUT)) {return "Oook!";}

    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>

    Hello, my  name is Inigo Montoya, you quoted my parent, prepare to cry.

  • (cs) in reply to devdas
    devdas:
    ammoQ:

    It becomes fairly obvious that some people lack the necessary education to recognize a bible parody, in this case Genesis chapter 2 (the story about Adam and Eve).


    Anonymous was referring to:
    Digitalbath:

    I once had a female coworker who happened to have that talent as well.  My favorite story is when some random morning, she overheard someone say that our tech lead was taking a personal day that day.  She exclaimed, "NO!!!  He has to come in today.  He HAS to help me fix what I broke."


    as sexist. I happen to agree with anonymous in this case.

    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. 

  • (cs) in reply to someone
    Anonymous:
    Anonymous:
    it becomes fairly obvious from this (and other) comments why female programmers do not exist.  Couldn't say coworker, couldn't say another programmer, had to say female programmer.  Lucky for all of us male programmers never make mistakes and are never singled out as a group for ridicule.  Once worked with a male programmer whose code was always half done and half right, but I never thought it was cause he was male, just that he was incompetent.
    public class FemaleProgrammer extends Programmer {
        // do not use at all ever
    }

    Yes, yes, I must be a real sexistic pig, but this IS funny :)

  • Got Lag? (unregistered) in reply to Kelsey

    Anonymous:
    This reminds me of touring through Australia's only nuclear reactor at Lucas Heights, near Sydney. Inside the reactor there is a button, which says

    'Do Not Press This Button'

    Apparently it was hooked up to a counter. Particularly fun on open to the public days.

    I'd be more worried about people being inside the reactor than pushing that button.

  • (cs) in reply to someone
    Anonymous:
    public class FemaleProgrammer extends Programmer {
        // do not use at all ever
    }


    What about:
    public final abstract class FemaleProgrammer extends Programmer {
    }

  • CDOG (unregistered) in reply to RayS

    hahahahahahahahahahahaa

    OMFG This stuff never ceases to amaze me.

    How about

    Public object IdontThinkThisFunctionisGoingToWork(int TheKey, object ImNotSureWhatThisParameterIsDoing)

  • Alex (unregistered) in reply to CDOG

    <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>

  • Fruktkake (unregistered) in reply to JoeBloggs

    I need to move to Australia!

  • ELIZA (unregistered) in reply to Got Lag?
    Got Lag?:
    Anonymous:
    This reminds me of touring through Australia's only nuclear reactor at Lucas Heights, near Sydney. Inside the reactor there is a button, which says 'Do Not Press This Button'Apparently it was hooked up to a counter. Particularly fun on open to the public days.
    I'd be more worried about people being inside the reactor than pushing that button.
    Sigh. He obviously meant the reactor facility rather than reactor, in much the same way that one often hears the entire hard disc assembly (disc or discs, bearings, reading and writing magnets, motors, case, and control and interface circuits) referred to as the hard disc.

Leave a comment on “The Forbidden Parameter”

Log In or post as a guest

Replying to comment #:

« Return to Article