- 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
Whoops, apolgies for the lack of indents in the above. I got confused and used StackOverflow layout.
Admin
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.
Admin
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?
Admin
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:
And reinforce what was considered to be a more modern habit:
Admin
Except they don't even follow their own copyright! Take a look at the second provision:
I don't see anywhere in that Hello, World! program that would print out the copyright notice and list of conditions.Admin
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?
Of course, I also don't like having to do this, either:
Having parameters be outputs seems pretty counter-intuitive.
It might be clearer with some saccharine syntax using an anonymous struct:
or
Other ideas?
Admin
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...
Admin
IsOK & IsNotOK
Not really all that much of a WTF, "if (somevar.isNotOK)" is more understandable by management than "if (!somevar.isOK)"
Admin
"They've copyrighted 'Hello, World'?! Those bastards!!"
Admin
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"?
Admin
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.
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.
Admin
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?
Admin
Admin
Admin
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.
Admin
The function addfunk is fine - it does just what it says. It adds an unpleasant, funky smell to the code.
Admin
captcha - paratus: apparatus to make asparagus
Admin
Should have been "project management" - usually those who used to be coders, but were never very good at it.
Admin
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.
Admin
WARNING - CONTENTS NOT NON UNINFLAMMABLE
Admin
"Inflammable" means "flammable"?
What a country!
Admin
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.
Admin
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!
Admin
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.
Admin
public function addfunk($one, $two, $one, $two, $three, $four) { getUp(); getOnUp(); stayOnTheScene(); likeASexMachine(); }
Admin
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.
Admin
No, but I've heard of Gilette's Razor
Admin
Admin
Cock up where?
Admin
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!"
Admin
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.
Admin
/** *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).
Admin
Counter-intuitive to me, anyway.
Arguments as return values? Algumemts as revurn talues? Algoomempts az rekuvn lal00z? UUUllllkkkooomemeptszzz.....
I'd prefer to have my inputs and outputs separate. Which is why I suggested syntax like this:
Admin
Admin
Admin
Admin
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...
Admin
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?
Admin
Fix it. I'm something and it's surely hurting me!
Admin
Another idea comes to mind:
instead of this
Anonymous Tuple Substitution.
It's the wave of the failu^H^H^H^H^HFuture!
Admin
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.
Admin
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?
Admin
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.
Admin
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.
Admin
I see it every day here. But with extra comments like "Rajneesh -- 4/9/2003". Thank <$deity> "Rajneesh" is 10,000 miles away.
Admin
Because I seem to remember having to work around Rajneesh's crappy code myself.
Admin
You mean like:
return Obj is Nothing
Admin
public function addfunk($one, $two, $one, $two, $three, $four) { $papa.possessions = new Bag(); }
Admin
Admin
So you don't like it simply because of the names?