- 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
This reminds me of a time when a buddy of mine was turning in code for a project in our Machine Learning class. He was getting frustrated with the code one night and put in a comment along the lines of:
//Instantiates your Mom
Our instructor, a man with a good sense of humor wrote a comment on the returned code going something like "Good work on the project, and my mother will be happy to know she has finally been instantiated.
Admin
Do people expect this kind of thing to work?
Unless that perl script had a LOT more random subjects and bodies, I'd get suspicious after a week or two when they started repeating (complete with typos).
How lazy do you have to be that you can't even write a new email every day?
Admin
The function names are hilarious! I especially like WhosYourDaddy(node). Go Pedro! [:D]
Admin
I would still give the guy points for ingenuity.
Admin
I never actually saw the emails, but I was suspicious when the manager in charge of catching this years ago repeatedly said the developer in question wouldn't make it to the meeting because he was watching the emails go out.
Yeah right. :P I guess that speaks volumes about the manager, also.
But did he get away with it? Yes. Well, until now. :)
Admin
That takes some pretty big balls. I mean, if this is pretty important and he's not really watching the 'emails go out' (WTF?), what if something went completely wrong?
Admin
I don't think I would call this person a bad coder. He's a lazy sneak, yes, but the idea is ingenious enough. Also, the other "interesting findings" aren't really WTFs, are they? Just shows that some coders have a sense of humour.
Admin
You might want to re-read the intro. Also, naming your methods and variables jokey names is WTF. Try staying up late trying to debug code with no comments and useless variable and method names and contextless debugging that includes commentary on completely usesless aspects of the process and you'll understand.
Admin
<font face="Courier New">Can you figure out WTF RiceCrispies(Snap(Crackle(Pop()))) is supposed to do?
I'm not able to see the humour in it when I'm trying to figure WTF is going on, the code is crashing, and the customer needs it fixed *yesterday*.
</font>
Admin
I am so using <font face="Courier New">theInfamousI++</font> as my default incrementer from now on!!
Admin
My favorite comment from my school days (from my own code) was:
// was drunk...will fix later.
This comment was followed by a string of variable names containing expletives. Amazingly, despite being drunk, the code worked. Just had to rename the variables before submission.
Admin
I think the obligatory first step is: "What do your <font face="Courier New">RiceCrispies()</font> say to you?"
It reminds me of when I was helping out other students in my High-School CS class all those years ago. One fellow had a pascal program with variable names like 'a', 'x', 'n' and so on. I suggested that he use "real names" instead of "just letters". He then showed me his revised code with names like "Shaq", "Jordan", "Pete", "Alex" and so on. :'(
Admin
hehe. As you are walking away, he's probably thinking
"real names.... real names, WHY should I put REAL names in my code? Well, I guess he knows better."
This is especially tough for people coming to programming from mathematics. In mathematical equations, if you see "ax + by", a, x, b and y are separate variables. In programming, you're just adding two variables. Oddly names ones, but still, just two.
Admin
What language do YOU use that you can use ++ in your identifier name? I'm a Microsoft guy and I truly don't know the answer to that because MS languages don't allow it.
Admin
Ok, we need to see the ascii image of Trogdor! A google search didn't find anything useful!
Admin
Admin
Haha, I love those var/func names [:D] Cool going! Great to brigten up some boring code
Admin
Reminds me of something I did in College for a class project. Essentially, just the reverse.
It was to process some mathematical algorithm, so I kept the simplic variable names of the original. (One was just "X", and there was a pointer called "ptr").
To document it, a wrote a short story -- a spoof of Sherlock Holmes --- which explained how it worked. There was a "Mysterious Mr. X" and a dog named "Ptr". (If I recall correctly, it was called "The Strange Case of Polly Nomial")
I probably still have the listing somewhere......
(Oh, and I got an "A" on it.....)
Admin
Awesome, never again do I have to stay late at work looking at pron, pretending I'm working. Y
Admin
I can't believe I'm correcting WTF code, but what he wants is not
@titles[rand($#titles)]
but rather
$titles[rand @titles]
In a 10-element array, @titles is 10, but $#titles is 9. He'll always miss the last option.
Admin
That is *awesome*!! I am writing all documentation in the form of prose from now on! I'm glad you got an A on it too--shows the instructor valued creativity (a good skill in programming) as well as proficiency.
Admin
Not without seeing the code, admittedly, but there is no context here. In the real code there may actually be comments there. As it is, it's funny.
Admin
One thing I like to do when naming my local variables is to prefix them with the function name, something like this:
Public Sub MyRiceCrispies( )
Dim MyRiceCrispies_I As Integer
Dim MyRiceCrispies_X As String
...
End Sub
This way you always know what function they came from, and it also helps the compiler optimize your code, making it less likely to confuse them with variables from another function.
Anyone else have any variable naming tips they'd like to share?
Admin
You're describing my very job. (Well, actually, you forgot to add one thing: do this on a live system that allows for maintenance only between 1 and 5am)
At least there is a reason behind many of the variable/function names mentioned ("<font face="Courier New">WhosYourDaddy</font>", for instance). Try the ones I have to deal with:
Admin
Perl will quite happily allow you to declare $theInfamousI as a variable, and then increment it via
$theInfamousI++
ex: $theInfamousI=0;
$theInfamousI++
print "$theInfamousI\n"; -> will print out "1"..
I'd have to suspect that's what was really going on with that little gem.
Admin
You don't know the context. Way to get yer panties in a bunch. A little humour in a small scope is hardly a maintenance issue.
Admin
my favorite was in some code a friend wrote that had the whitespace-trimmer KillWhitey()
Admin
Is that Swedish or something?
Admin
I can never tell if you are joking with this stuff. I'm just going to assume you are.
Admin
Admin
I use ROT13 on all my variable names. For security.
Admin
You can always use the characters from the Simpsons. The nice thing about that is that it's almost impossible to run out of names.
Admin
<FONT face="Courier New">RiceCrispies(Snap(Crackle(Pop() ) ) )</FONT>
<FONT face="Courier New">Ugh.</FONT>
<FONT face="Courier New">With a joke name, you know it wont be called from many places so you can just get rid of it.</FONT>
<FONT face="Courier New">If the names are real-world,use </FONT><FONT face="Courier New">Introduce Explaining Variable.</FONT>
<FONT face="Courier New"></FONT>
<FONT face="Courier New"></FONT>
<FONT face="Courier New"></FONT>
Admin
I had a function along these lines once... spankthekids() fired from the controller and rebooted all the child nodes (machine controllers) when they got unruly and nothing but a systemwide restart would do the trick (read: When admin decided we should reboot erverything... just to see if it helps)...
Admin
Hungarian, actually. Problem is, I don't speak Hungarian.
Admin
Brings a whole new meaning to the phrase 'hungarian notation'
Admin
the Trogdor comes in the NIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIGHT!
Admin
I have to confess to committing such silliness back in my first semi-professional programming job, a POS (in both senses of the term) for a store I was working for. The sordid details can all be found here (a slightly different version can also be seen here).
Among the groaners were:
Admin
Admin
Aaargh, your forum software formatted that correctly in the preview, which is definitely a WTF.
Anyway, the point I was trying to make: Scheme has no reserved identifiers at all, and almost all characters are allowed in identifiers. So, "++" is a valid identifier in Scheme...
Admin
When I get bored while programming, I also tend to use such names for variables, methods etc. When I was at the university, I had to write a very boring piece of source. Because I read some very famous comic books at that time ("Werner"), I only used the comic sounds as names. It was fully documented, and the program just did what it was supposed to be, but just reading the source without the comments wouldn't give you a single hint, what this program was supposed to do.
Admin
If it's not too unclear I find it rather funny to do things a little different. (If you don't exaggerate, that is [:D]) All work and no play makes Jack a dull boy...
Admin
I go one step further -- I use Hungarian Notation.
Admin
Admin
{I think he just meant that the variable was "theInfamousI". He didn't say it that way, but I also can't imagine any language that would support that as a legal variable name.}
<font size="4">Try FORTH or FACTOR to start with, I'm not sure but I think even Smalltalk, and some of the functional languages will allow this.
This entire discussion has brought tears to my eyes - it has been so funny. Over the last tweny odd years, the industry has come up with some doozies.
Enjoy your weekend Ladies and Gentlemen.</font>
Admin
OK, I found the list. However, 20 year old computer listings (on greenbar paper) don't OCR very well, so post it, I've had to scan it as images and post the GIFs.
If you want to read it, it's at:
http://honestillusion.com/photos/the_strange_case_of_polly_nomial
Admin
That is an awesome story james
Admin
Not only was that a good read, but it had to be the most creative use of variable names *and* comment space I've ever seen. The intersection of Sherlock Holmes (er.. "Houses"), aptly-named biblical references, lyrics/poetry, and a double-helix indentation scheme.
...although if that was in production (commercial) code, I'd smack you with a trout.
10/10 WTF points. (would've been a '9' but the code obviously predates Trogdor)
Admin
The variable names remind me of a program I wrote at one point that involved a leftist heap (http://www.cs.dartmouth.edu/~chepner/cs15/notes/16_heaps.html). I called the whole structure a commie_heap, and named all the local variables within the implementation after communist leaders, so you'd have functions like:
commie_heap_merge(struct commie_heap *lenin, struct commie_heap *trotsky)
...and so on.
Admin
C and C++ would NEVER confuse a local variable with 'another variable from another function'. It just can't happen.
If I want to name a local variable the same as something already global, I usually put an l_ in front of the name. There is no need to put the entire function name in front of a variable like you do if writing in C and C++, and it really contributes nothing to the clarity of the code whatsoever.
Unless your I or X are used trivially, you would do better to spend your time naming them something other than 'I' and 'X'.