• Jay (unregistered)

    Whoops, apolgies for the lack of indents in the above. I got confused and used StackOverflow layout.

  • I <3 scala (unregistered) in reply to C-Octothorpe
    C-Octothorpe:
    Loren Pechtel:
    josefx:
    The MutableBoolean should be obvious for anyone familiar with the java wrapper classes. java.lang.Boolean is not Mutable so MutableBoolean is a good name for boolean wrapper with a public non final value field

    Even though I've never used Java I immediately understood what was going on. It's not a WTF unless it's duplicating library functionality.

    hoodaticus:
    ac:
    Isn't the MutableBoolean just a way to make the boolean (value) type into a reference type ("box" it, in .NET terms)? Because values types are passed by uh... value, you can't change the original value, so it appears "constant".

    Not that this is already covered by the java.lang.Boolean class or anything...

    This does nothing that a simple local variable wouldn't do.

    This allows pass-by-reference instead of pass-by-value.

    hoodaticus:
    I still don't get the point. If you have multiple classes sharing the same boolean, surely that boolean is significant enough that it has a property name in a class that is much more meaningful than MutableBoolean.

    Sharing it with a delegate, perhaps?

    So this is to essentially get around a limitation of java where everything is passed by value, including objects? Man, I am so glad I haven't touched java in years...

    Limitation? I like my programming languages without side effects on primitive type arguments, thank you very much.

    If you need to pass variables by reference there is something inherently dangerous about your function and you should consider instead returning multiple values in a tuple or some other structure.

  • Syam (unregistered) in reply to Ton

    Actually, I didn't quite understand why this is so stupid. As far as I can see, a variable named MAX_NUMBER_ATTACHMENTS is used to determine if some sort of logging is enabled. Why is this so terrible? Can anybody enlighten me?

  • Hortical (unregistered) in reply to C-Octothorpe
    C-Octothorpe:
    Artemus Harper:
    The best usecase of using a MutableBoolean is when a method needs to return more than one value [in java]. E.g.
    public CoolFactor calculateCoolness(Stuff stuff, Stuff moreStuff, MutableBoolean resultIsAswome)
    
    At least in .Net, you have the option of passing a value by ref, and objects are always passed by ref. Heck you can even pass an objects reference by ref so you can do reference swapping successfully, not that there are too many situations where you would, but...

    One of the first things I noticed about Java was that there was no passing by reference. I always wondered why.

    Perhaps it was to avoid patterns like:

    int doSomething(int &x){
        x++;
        if (x > LIMIT)
            return STATUS_OVERFLOW;
        return STATUS_OK;
    }

    And reinforce what was considered to be a more modern habit:

    int doSomething(int x){
        x++;
        if (x > LIMIT)
            throw new Exception();
        return x;
  • Machtyn (unregistered) in reply to Mcoder
    Mcoder:
    Wonk:
    1) Write "Hello World" Program 2) Copyright program 3) ???? 4) Profit!!

    Yep. That's Oracle.

    1. Write "Hello World" program
    2. Copyright program
    3. Have some random site (TDWTF) distribute your program verbatim
    4. Sue the hell out of random site. That'll teach them to obey copyrights
    5. Profit!!! (For the lawyers)

    Except they don't even follow their own copyright! Take a look at the second provision:

    Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    I don't see anywhere in that Hello, World! program that would print out the copyright notice and list of conditions.

  • Hortical (unregistered) in reply to I <3 scala
    I <3 scala:
    C-Octothorpe:
    So [pass a mutable value wrapper] is to essentially get around a limitation of java where everything is passed by value, including objects? Man, I am *so* glad I haven't touched java in years...

    Limitation? I like my programming languages without side effects on primitive type arguments, thank you very much.

    If you need to pass variables by reference there is something inherently dangerous about your function and you should consider instead returning multiple values in a tuple or some other structure.

    (here comes aimless musing)

    Even though I'm used to java, I still don't like situations where I have to create a new class just to hold return values from a function. There's a divide/remainder function in the math class (BigInteger) that returns an array of length 2 for the two return values. That always seemed weird to me.

    What if I want to return multiple values that are not of the same type? Do I do this?

    Object[] retVals = function();
    ClassA a = (ClassA) retVals[0];
    ClassB b = (ClassB) retVals[1];
    ClassC c = (ClassC) retVals[2];

    Of course, I also don't like having to do this, either:

    ClassA a;
    ClassB b;
    ClassC c;
    function(out a, out b, out c)

    Having parameters be outputs seems pretty counter-intuitive.

    It might be clearer with some saccharine syntax using an anonymous struct:

    A a;
    B b;
    C c;
    [a, b, c] = function()

    or

    [A a, B b, C c] = function()

    Other ideas?

  • (cs) in reply to Jay
    Jay:
    Yes, something like MutableBoolean allows you to bypass Java's pass-by-value paradigm, which arguably could be a tacit admission of a defect in Java. But it could also be used to "promote" a primitive to an Object, thus allowing it to be used in contexts where otherwise it would not be allowed. I think there's good reason for a primitive vs object distinction, but yes, it does create this extra complexity at times.

    Here's a rather obvious example of where a MutableBoolean would be useful:

    HashMap<String,MutableBoolean> products=new HashMap<String,MutableBoolean>();
    public void setActiveFlag(String product)
    {
      MutableBoolean active=products.get(product);
      if (active==null)
      {
        active=new MutableBoolean(true);
        products.put(product,active);
      }
      active.value=... some logic that decides if it's active ...
    }
    

    Yes, you could use a Boolean instead and create a new Boolean every time the value changes. But that's a lot of extra object creation and destruction, and it takes a few more lines of code to do. So this solution means fewer lines of code (equals easier to maintain) plus faster run time. Win/win.

    I routinely create MutableIntegers for just this purpose. Then I can write

    MutableInteger n=collection.get(key);
    n.value+=1;
    

    instead of

    Integer n=collection.get(key);
    int value=n.intValue()+1;
    Integer newN=new Integer(value);
    collection.put(key, newN);
    

    The first method can be read and understood in an instant. The second requires at least a few extra seconds of thought, and someone reading it quickly is more easily confused. (And yes, we could cram it all into one line of code and eliminate the temporary variables, like:

    Integer n=collection.get(key);
    collection.put(key, new Integer(n.intValue()+1));
    

    I guess it's debatable if that is better or worse.)

    Okay, a couple of seconds isn't a lot. But when you have programs filled with unnecessary complexities, each of which takes an extra couple of seconds of your time to figure out, it adds up.

    captcha: sino. I tried sqrt(1-cos2o), but for some reason it didn't accept that.

    Bah - you are thinking too much into this

    MutableBoolean must have been created by someone that gets paid by coc (characters of code)

    Instead of

    boolean foo=true; boolean bar=false;

    they code MutableBoolean foo = new MutableBoolean(true); MutableBoolean bar = new MutableBoolean(false);

    By doing this they get paid almost 3 times as much...

  • (cs)

    IsOK & IsNotOK

    Not really all that much of a WTF, "if (somevar.isNotOK)" is more understandable by management than "if (!somevar.isOK)"

  • (cs)

    "They've copyrighted 'Hello, World'?! Those bastards!!"

  • E. Pesker (unregistered) in reply to Syam
    Syam:
    Actually, I didn't quite understand why this is so stupid. As far as I can see, a variable named MAX_NUMBER_ATTACHMENTS is used to determine if some sort of logging is enabled. Why is this so terrible? Can anybody enlighten me?

    wow- just had sort of a personal epiphany here over this comment.

    I've (silently) read TDWTF intermittently for years now, and would generally think a comment such as this is obviously a troll- and not a very good one. But now I'm not quite so sure, as I've recently had a number of heated arguments over exactly this sort of thing, which I've consistently lost.

    What does one do in the face of positions such as "well, it works" and "it's not hurting anything"?

  • (cs) in reply to Marc
    Marc:
    Normally in a class you'd define functions that don't require the object pointer as static methods. However, in some cases it's useful that a method can be called both with or without object pointer.

    A bit exotic, no doubt. But there are perfectly legitimate uses for "this" being null.

    In my strong opinion, no, there aren't. You can't rely on being able to call a method on a null object; if it works it's by "accident." Granted, it will probably work, but it really is not portable. There has to be a damn good reason to deliberately insert undefined behavior. There could easily be a situation where once the optimizer gets its hands on the code, what you come out doesn't match what you expect. Do you understand what your optimizer is doing well enough to know that won't happen?

    Code that relied on calling a function with "this" as NULL would never make it into a code base I controlled, and if that situation showed up unintentionally it would get marked as a severe bug.

    Machtyn:
    Except they don't even follow their own copyright! Take a look at the second provision:
    Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    I don't see anywhere in that Hello, World! program that would print out the copyright notice and list of conditions.
    Read that statement again. Nowhere does it say that the code needs to print that out: it says that the disclaimer needs to be provided in the documentation and/or other materials provided with the distribution.

    Addendum (2011-07-20 14:28): So apparently the undefined behavior argument is not quite as strong as I thought, but it seems like it's not definitely defined. And as far as I'm concerned, that's good enough.

    Addendum (2011-07-20 14:32): I take that back, it is definitely undefined:

    If a nonstatic member function of a class X is called for an object that is not of type X, or of a type derived from X, the behavior is undefined. (C++ standard, 9.3.1, para. 1.)

    The null pointer does not refer to an object of type X.

    Thanks to the GMan's reply to this Stack Overflow question for the explanation and reference, which I then checked with my copy of the standard.

  • (cs) in reply to Hortical
    Hortical:
    I <3 scala:
    C-Octothorpe:
    So [pass a mutable value wrapper] is to essentially get around a limitation of java where everything is passed by value, including objects? Man, I am *so* glad I haven't touched java in years...

    Limitation? I like my programming languages without side effects on primitive type arguments, thank you very much.

    If you need to pass variables by reference there is something inherently dangerous about your function and you should consider instead returning multiple values in a tuple or some other structure.

    (here comes aimless musing)

    Even though I'm used to java, I still don't like situations where I have to create a new class just to hold return values from a function. There's a divide/remainder function in the math class (BigInteger) that returns an array of length 2 for the two return values. That always seemed weird to me.

    What if I want to return multiple values that are not of the same type? Do I do this?

    Object[] retVals = function();
    ClassA a = (ClassA) retVals[0];
    ClassB b = (ClassB) retVals[1];
    ClassC c = (ClassC) retVals[2];

    Of course, I also don't like having to do this, either:

    ClassA a;
    ClassB b;
    ClassC c;
    function(out a, out b, out c)

    Having parameters be outputs seems pretty counter-intuitive.

    It might be clearer with some saccharine syntax using an anonymous struct:

    A a;
    B b;
    C c;
    [a, b, c] = function()

    or

    [A a, B b, C c] = function()

    Other ideas?

    IMO, using an array to return multiple values just screams of code smell. It's easy to misuse, you have boxing/unboxing overhead, not strongly typed and it's more difficult to read. Out (and ref) parameters allow type safety, and give you clean and readable code, especially because you have to explicitly use them which gives the reader hints. As far as counter-intuitive goes, PL/SQL and TSQL would like to respectfully disagree.

    From a .Net perspective, the touple would be perfect in this scenario because it's generic (new Touple<int, string, bool, MyObject>), but it starts to loose meaning when you get something like this: new Touple<string, string, string, string, string>.

    This is where out (or ref) parameters shine, IMO. Strongly typed, and you know exactly what you're dealing with. There is no accidentally giving the wrong meaning to the wrong index of an array, easy to maintain, clean, and it's self documenting.

    string firstName; string lastName; bool isCool;

    DoStuff(out firstName, out lastName, out isCool);

    has more meaning than

    var items = DoStuff(); string firstName = (string)items[0]; // Are you sure it's index 0, not 2?

  • (cs) in reply to Silfax
    Silfax:
    IsOK & IsNotOK

    Not really all that much of a WTF, "if (somevar.isNotOK)" is more understandable by management than "if (!somevar.isOK)"

    Why is management looking at your code base?
  • (cs) in reply to Syam
    Syam:
    Actually, I didn't quite understand why this is so stupid. As far as I can see, a variable named MAX_NUMBER_ATTACHMENTS is used to determine if some sort of logging is enabled. Why is this so terrible? Can anybody enlighten me?
    THe WTF is two-fold: 1) The name of MAX_NUMBER_ATTACHMENTS *seems* to have absolutely nothing to do with logging 2) MAX_NUMBER_ATTACHMENTS is probably a constant, and the number "1", is definitely constant. Testing one constant against another seems, well, kinda stupid...
  • Ton (unregistered) in reply to E. Pesker
    E. Pesker:
    Syam:
    Actually, I didn't quite understand why this is so stupid. As far as I can see, a variable named MAX_NUMBER_ATTACHMENTS is used to determine if some sort of logging is enabled. Why is this so terrible? Can anybody enlighten me?

    wow- just had sort of a personal epiphany here over this comment.

    I've (silently) read TDWTF intermittently for years now, and would generally think a comment such as this is obviously a troll- and not a very good one. But now I'm not quite so sure, as I've recently had a number of heated arguments over exactly this sort of thing, which I've consistently lost.

    What does one do in the face of positions such as "well, it works" and "it's not hurting anything"?

    One finds the worst piece of code written in that fashion and one makes one of those arguers responsible for maintaining that piece of code. If one reall doesn't like the person, make them implement new features as well.

  • (cs)

    The function addfunk is fine - it does just what it says. It adds an unpleasant, funky smell to the code.

  • alnite (unregistered) in reply to C-Octothorpe
    2) MAX_NUMBER_ATTACHMENTS is probably a constant, and the number "1", is definitely constant. Testing one constant against another seems, well, kinda stupid...
    That's TDWTF right there..

    captcha - paratus: apparatus to make asparagus

  • (cs) in reply to C-Octothorpe
    C-Octothorpe:
    Silfax:
    IsOK & IsNotOK

    Not really all that much of a WTF, "if (somevar.isNotOK)" is more understandable by management than "if (!somevar.isOK)"

    Why is management looking at your code base?

    Should have been "project management" - usually those who used to be coders, but were never very good at it.

  • (cs) in reply to ac
    ac:
    Isn't the MutableBoolean just a way to make the boolean (value) type into a reference type ("box" it, in .NET terms)? Because values types are passed by uh... value, you can't change the original value, so it appears "constant".

    Not that this is already covered by the java.lang.Boolean class or anything...

    This use case is NOT covered by java.lang.Boolean because that class is not mutable.

    The programmer MIGHT have been wanting to minimize all the auto-boxing that would occur when inserting "boolean" (lowercase) into maps, as java invisibly (as of 6) converts boolean into Boolean since maps require objects as keys/values. But that seems silly as I assume (hope) that java simply uses the static Boolean.TRUE/.FALSE objects instead of creating new ones when autoboxing.

    As other have pointed out this might also be a way to pass booleans by reference (instead of value).

    Overall I don't see how this is a true WTF - just a sign that bad programming might exist somewhere else.

  • (cs)

    WARNING - CONTENTS NOT NON UNINFLAMMABLE

  • Dr. Nick (unregistered) in reply to shadowman
    shadowman:
    WARNING - CONTENTS NOT NON UNINFLAMMABLE

    "Inflammable" means "flammable"?

    What a country!

  • (cs) in reply to mcbarron
    mcbarron:
    ac:
    Isn't the MutableBoolean just a way to make the boolean (value) type into a reference type ("box" it, in .NET terms)? Because values types are passed by uh... value, you can't change the original value, so it appears "constant".

    Not that this is already covered by the java.lang.Boolean class or anything...

    This use case is NOT covered by java.lang.Boolean because that class is not mutable.

    The programmer MIGHT have been wanting to minimize all the auto-boxing that would occur when inserting "boolean" (lowercase) into maps, as java invisibly (as of 6) converts boolean into Boolean since maps require objects as keys/values. But that seems silly as I assume (hope) that java simply uses the static Boolean.TRUE/.FALSE objects instead of creating new ones when autoboxing.

    As other have pointed out this might also be a way to pass booleans by reference (instead of value).

    Overall I don't see how this is a true WTF - just a sign that bad programming might exist somewhere else.

    I remember having to maintain a class with a MutableBoolean in it a few years ago. Not sure of the details but it might have had something to do with the fact that it was pre-Java 1.4 and there were limitations in v 1.3 which a MutableBoolean got round more or less neatly. Even then I had a good long think about how it could have been done better but in the end I left it as it was because it was perfectly adequate.

  • Bob Fowler (unregistered) in reply to brandorf

    Absolutely, It's sad to say, but for binding, it's much better to have these "extra" get properties. Makes the code just a touch fatter (but you can usually use snippets to generate them automatically), but simplifies the binding to WPF / Silverlight no end!

  • E. Pesker (unregistered) in reply to Ton

    ah- thanks, but I've clearly not given enough context here.

    The main "arguer" is the head of development. He does in fact maintain much of this, and adds new features in much the same style. He just doesn't see the value in clean code- actually doesn't seem to think it's possible.

    Does tend to have a good attitude about it all though. Thinks it's pretty funny when "fixes" cause other bugs and such.

    Quite frustrating, but I do get paid.

  • James Brown (unregistered)

    public function addfunk($one, $two, $one, $two, $three, $four) { getUp(); getOnUp(); stayOnTheScene(); likeASexMachine(); }

  • Christopher (unregistered)

    That "Hello World" program is useless! It doesn't support any command-line arguments, much less internationalization.

    See GNU Hello for a real Hello World application.

  • Dan (unregistered) in reply to C-Octothorpe
    C-Octothorpe:
    Riory:
    "While taking a stroll through the code on a new project, I came across a fantabulous override of ToString," Jay writes, "I guess you never know when this will be null."

    It turns out it is possible, though not in C# but still...

    http://stackoverflow.com/questions/3143498/why-check-this-null

    So my guess is author of "this == null" may be former MS employee...

    Have you ever heard of Hanlon's razor?

    No, but I've heard of Gilette's Razor

  • Dazed (unregistered) in reply to Silfax
    Silfax:
    MutableBoolean must have been created by someone that gets paid by coc (characters of code)

    ...

    By doing this they get paid almost 3 times as much...

    You mean it's just a coc-up?
  • Sickfacts (unregistered) in reply to Dazed
    Dazed:
    Silfax:
    MutableBoolean must have been created by someone that gets paid by coc (characters of code)

    ...

    By doing this they get paid almost 3 times as much...

    You mean it's just a coc-up?

    Cock up where?

  • (cs) in reply to E. Pesker
    E. Pesker:
    ...I've recently had a number of heated arguments over exactly this sort of thing, which I've consistently lost.

    What does one do in the face of positions such as "well, it works" and "it's not hurting anything"?

    Well, considering that "winning" the argument requires your opponent to get smarter, I'd say there's not much you can do. Of course, heavy doses of sarcasm may be therapeutic.

    Them: "well, it works" You: "yes, but it doesn't work properly..."

    Them: "it's not hurting anything" You: "-is too, it's hurting my eyes right now!"

  • (cs) in reply to boog
    boog:
    Public Function IsObjNothing(ByRef poObject As Object) As Boolean
        '***** 04/21/2004 - corrected function IsObjNothing expression type
        'IsObjNothing = (TypeName(poObject) = Nothing)
        IsObjNothing = (TypeName(poObject).ToUpper = "NOTHING") End Function
    Can't you just look at the object to see if it's nothing? I mean, that's all the function is doing. The fact that the original developer thought to add this function to the codebase to begin with makes the WTF (is nothing case-sensitive?) less of a surprise.

    Funny use for the word "corrected" though. :)

    Which would be only one of the reasons why I submitted it. I actually became physically angry when I came across this while debugging one day, and the VS plug-in to submit it here just allowed me to vent a little. I didn't think it would make the front page, but there is a lot of WTFery in it. Not only is it completely useless, it's also poor performance, which is the number one complaint about the software, which costs over $1 million at the install, and over $100,000 per year. Almost every function in the codebase is like this, but that one is "representative" without being too long. You should see their SQL - I can't actually post any of it because it would be instantly recognizable as their particular style of bad SQL.

  • Erik (unregistered)

    /** *Makes the following dialog not non-uninvisible */

    Having spent several years reviewing the code and associated comments (when you actually got them) written by offshore developers, I feel somewhat qualified to attempt to parse the meaning of this comment. I had to decipher plenty that looked that bad or worse.

    Let's break it down and find a likely meaning for what each successive negative might actually be doing:

    • dialog is visible Dialog is shown to the user.

    • dialog is invisible Dialog is hidden from the user.

    • dialog is uninvisible My guess is that this abortion of language indicates an action, switching the dialog from invisible to visible.

    • dialog is non-uninvisible Based on the previous assumption, this would mean that a flag is set preventing the dialog from being switched from invisible to visible.

    • dialog is made not non-uninvisible Therefore, the method is changing the value of the flag, allowing the dialog to be switched from invisible to visible (though not actually making that switch itself).

  • Hortical (unregistered) in reply to C-Octothorpe
    C-Octothorpe:
    As far as counter-intuitive goes, PL/SQL and TSQL would like to respectfully disagree.

    Counter-intuitive to me, anyway.

    Arguments as return values? Algumemts as revurn talues? Algoomempts az rekuvn lal00z? UUUllllkkkooomemeptszzz.....

    C-Octothorpe:
    This is where out (or ref) parameters shine, IMO. Strongly typed, *and* you know exactly what you're dealing with. There is no accidentally giving the wrong meaning to the wrong index of an array, easy to maintain, clean, and it's self documenting.

    I'd prefer to have my inputs and outputs separate. Which is why I suggested syntax like this:

    String firstName;
    String lastName;
    boolean cool;
    [firstName, lastName, cool] = DoStuff();
    
    public [String, String, boolean] doStuff()
    {
        return ["C", "Octothorpe", Boolean.DEFINITELY_NOT];
    }
    
  • (cs) in reply to jasmine2501
    jasmine2501:
    You should see their SQL - I can't actually post any of it because it would be instantly recognizable as their particular style of bad SQL.
    I know what you mean. I've had to maintain code like this before, where the code is so uniquely awful that it is recognizable. Also, any attempt to anonymize it would actually require improving the code, leaving the WTF lost in translation.
  • Fonseca (unregistered)
    "As if this function isn't useless enough as it is, note that the unit is off," notes Mike Wacker, "timeInSeconds should really be timeInMilliseconds."
    Huh, nope, it really is timeInSeconds. TRWTF is the submitter's comment, once again.
  • Fonseca (unregistered)
    Public Function IsObjNothing(ByRef poObject As Object) As Boolean '***** 04/21/2004 - corrected function IsObjNothing expression type 'IsObjNothing = (TypeName(poObject) = Nothing) IsObjNothing = (TypeName(poObject).ToUpper = "NOTHING") End Function
    ... and what's wrong with this fix? Useless function, but at least it now works.
  • (cs) in reply to Hortical
    Hortical:
    Counter-intuitive to me, anyway.
    Fair enough...
    Hortical:
    Arguments as return values? Algumemts as revurn talues? Algoomempts az rekuvn lal00z? UUUllllkkkooomemeptszzz.....
    Um, you lost me at "UUUllllkkkooomemeptszzz"...
    Hortical:
    String firstName;
    String lastName;
    boolean cool;
    [firstName, lastName, cool] = DoStuff();
    

    public [String, String, boolean] doStuff() { return ["C", "Octothorpe", Boolean.DEFINITELY_NOT]; }

    Damnit, just don't tell anyone, alright!

    I was actually going to suggest returning a dynamic object, but that is about as maintainable as an array...

    What WOULD be nice, at least in .Net, is to allow (somehow) returning anonymous types from method calls. I'm not sure how the syntax would look, but it would be sweet...

  • (cs)

    So I copyrighted my own copy of Hello World about 17 years ago. It looks like Oracle owes me some money.

    Sure, it was in C, but translations are within the scope of copyright, aren't they?

  • (cs) in reply to E. Pesker
    E. Pesker:
    What does one do in the face of positions such as "well, it works" and "it's not hurting anything"?

    Fix it. I'm something and it's surely hurting me!

  • Guess Who? (unregistered) in reply to C-Octothorpe
    C-Octothorpe:
    Hortical:
    Counter-intuitive to me, anyway.
    Fair enough...
    Hortical:
    Arguments as return values? Algumemts as revurn talues? Algoomempts az rekuvn lal00z? UUUllllkkkooomemeptszzz.....
    Um, you lost me at "UUUllllkkkooomemeptszzz"...
    Hortical:
    String firstName;
    String lastName;
    boolean cool;
    [firstName, lastName, cool] = DoStuff();
    

    public [String, String, boolean] doStuff() { return ["C", "Octothorpe", Boolean.DEFINITELY_NOT]; }

    Damnit, just don't tell anyone, alright!

    Another idea comes to mind:

    public void transmit(String fn, String ln, boolean c){
        // send over network
    }
    public [String, String, boolean] doStuff(){
        return ["C", "Octothorpe", Boolean.SURE_WHY_NOT];
    }
    
    transmit(doStuff());
    

    instead of this

    string firstName;
    string lastName;
    bool cool;
    DoStuff(out firstName, out lastName, out cool);
    Transmit(firstName, lastName, cool);
    

    Anonymous Tuple Substitution.

    It's the wave of the failu^H^H^H^H^HFuture!

  • (cs) in reply to Fonseca
    Fonseca:
    Public Function IsObjNothing(ByRef poObject As Object) As Boolean '***** 04/21/2004 - corrected function IsObjNothing expression type 'IsObjNothing = (TypeName(poObject) = Nothing) IsObjNothing = (TypeName(poObject).ToUpper = "NOTHING") End Function
    ... and what's wrong with this fix? Useless function, but at least it now works.

    What's wrong with it is that customers are paying for that kind of thing to be fixed when it shouldn't be there in the first place. AND - all of the fixes they ever do involve commenting out the original code and writing the new code there, which does nothing but hurt readability and has no value when you have a source control system. If someone wants to know what the function looked like in the past, they can look up the history, and there is no reason to leave the original code in the file.

    Which is not to mention that I think if the object is actually NULL, this method throws an exception. AND, they never bother to return the result - not sure why the compiler allows that.

  • Rich (unregistered)

    I don't have a Solaris machine handy, but I remember 'true' on a Solaris box was nothing but comments. I think what happens: if there's no shebang or other magic number in the file, it's passed to /bin/sh, which sees a file that is nothing but comments, and it does in effect, exit(SUCCESS)

    So, /usr/bin/true is 100% comments and is still useful, beat that.

    CAPTCHA: appellatio... your name in West Virginia perhaps?

  • E. Pesker (unregistered) in reply to boog
    boog:
    E. Pesker:
    ...I've recently had a number of heated arguments over exactly this sort of thing, which I've consistently lost.

    What does one do in the face of positions such as "well, it works" and "it's not hurting anything"?

    Well, considering that "winning" the argument requires your opponent to get smarter, I'd say there's not much you can do. Of course, heavy doses of sarcasm may be therapeutic.

    Them: "well, it works" You: "yes, but it doesn't work properly..."

    Them: "it's not hurting anything" You: "-is too, it's hurting my eyes right now!"

    Thanks- this made me laugh, which really does help.

    And yah- have taken to muttering, sarcastically and otherwise. Have sometimes had the mutterings come back to later as this "great new idea I just had", so maybe "making my opponent smarter" is a reasonable approach- I just need more patience.

  • (cs) in reply to jasmine2501
    jasmine2501:
    ...all of the fixes they ever do involve commenting out the original code and writing the new code there, which does nothing but hurt readability and has no value when you have a source control system. If someone wants to know what the function looked like in the past, they can look up the history, and there is no reason to leave the original code in the file.
    This was standard practice in my last job. I remember hearing the argument that having the old code commented out makes it quicker to see what was changed, because you don't have to dig through history to find an old version.

    Of course, I only heard this argument from people who never successfully used a source control system in their lives.

    Addendum (2011-07-20 17:59): I forgot to mention: when some of these people had to use source control, they still made backup copies of files they were changing, happily and blindly committing each backup to the repository too.

    HelloWorld.bak HelloWorld.2.java HelloWorld.java.old HelloWorld.java.old.old HelloWorld.old

    ...and so on.

  • (cs) in reply to jasmine2501
    jasmine2501:
    Fonseca:
    Public Function IsObjNothing(ByRef poObject As Object) As Boolean '***** 04/21/2004 - corrected function IsObjNothing expression type 'IsObjNothing = (TypeName(poObject) = Nothing) IsObjNothing = (TypeName(poObject).ToUpper = "NOTHING") End Function
    ... and what's wrong with this fix? Useless function, but at least it now works.

    What's wrong with it is that customers are paying for that kind of thing to be fixed when it shouldn't be there in the first place. AND - all of the fixes they ever do involve commenting out the original code and writing the new code there, which does nothing but hurt readability and has no value when you have a source control system. If someone wants to know what the function looked like in the past, they can look up the history, and there is no reason to leave the original code in the file.

    <<snip>>

    What you're missing is that people who use the "beat the code into submission" methodology do not use source control.

    I see it every day here. But with extra comments like "Rajneesh -- 4/9/2003". Thank <$deity> "Rajneesh" is 10,000 miles away.

  • (cs) in reply to D-Coder
    D-Coder:
    What you're missing is that people who use the "beat the code into submission" methodology do not use source control.

    I see it every day here. But with extra comments like "Rajneesh -- 4/9/2003". Thank <$deity> "Rajneesh" is 10,000 miles away.

    I'm going to go out on a limb and guess that your code is touching Oracle somehow. Am I wrong?

    Because I seem to remember having to work around Rajneesh's crappy code myself.

  • PRMan (unregistered) in reply to boog
    boog:
    Public Function IsObjNothing(ByRef poObject As Object) As Boolean
        '***** 04/21/2004 - corrected function IsObjNothing expression type
        'IsObjNothing = (TypeName(poObject) = Nothing)
        IsObjNothing = (TypeName(poObject).ToUpper = "NOTHING") End Function
    Can't you just look at the object to see if it's nothing? I mean, that's all the function is doing. The fact that the original developer thought to add this function to the codebase to begin with makes the WTF (is nothing case-sensitive?) less of a surprise.

    Funny use for the word "corrected" though. :)

    You mean like:

    return Obj is Nothing

  • eVil (unregistered)

    public function addfunk($one, $two, $one, $two, $three, $four) { $papa.possessions = new Bag(); }

  • verto (unregistered) in reply to C-Octothorpe
    C-Octothorpe:
    hoodaticus:
    ac:
    Isn't the MutableBoolean just a way to make the boolean (value) type into a reference type ("box" it, in .NET terms)? Because values types are passed by uh... value, you can't change the original value, so it appears "constant".

    Not that this is already covered by the java.lang.Boolean class or anything...

    This does nothing that a simple local variable wouldn't do.
    TRWTF is Java... http://commons.apache.org/lang/api-2.5/org/apache/commons/lang/mutable/MutableBoolean.html http://download.oracle.com/javase/6/docs/api/java/util/concurrent/atomic/AtomicBoolean.html http://stackoverflow.com/questions/3786825/java-volatile-boolean-vs-atomicboolean http://stackoverflow.com/questions/1385481/mutable-boolean-field-in-java

    And fucking of course the red-headed step child nobody loves or wants, akismet...

    I saw all those links and assumed you were linking to xkcd, so I didn't follow them.

  • damnum (unregistered) in reply to C-Octothorpe
    C-Octothorpe:
    Syam:
    Actually, I didn't quite understand why this is so stupid. As far as I can see, a variable named MAX_NUMBER_ATTACHMENTS is used to determine if some sort of logging is enabled. Why is this so terrible? Can anybody enlighten me?
    THe WTF is two-fold: 1) The name of MAX_NUMBER_ATTACHMENTS *seems* to have absolutely nothing to do with logging 2) MAX_NUMBER_ATTACHMENTS is probably a constant, and the number "1", is definitely constant. Testing one constant against another seems, well, kinda stupid...

    So you don't like it simply because of the names?

Leave a comment on “Not Non-uninvisible, addfunk(), and More”

Log In or post as a guest

Replying to comment #:

« Return to Article