- 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
for(;;) {
echo "Am I frist?";
}
Admin
Haven't the last two come up before? I feel like the last one especially was almost word-for-word posted some time ago ($cat instead of $category).
Admin
isn't a WTF. It happens when the logic changes frequently. Rather than merge the two branches and then try to remember what the condition was when the logic requests diverging pathways, you simply leave an
if
statement stub that you can expect later.Coding to specification is like walking on water. It's easier when it's frozen.
Admin
Admin
Adam, the most important thing about an if statement is to get the braces on separate lines. I think your cow orker has learned that lesson admirably.
Admin
The first snippet would be fixed by using
instead of and properly closing the input tag.Addendum (2013-02-28 08:09): Also, the name fits the dog better.
Admin
Admin
Admin
Or, y'know, you could let version control do its job and not leave redundant code all over the place.
Admin
The more ancient segments of the code base at work are littered with things like:
Of course, the language it's written in doesn't actually support while loops (well, not as while loops). Or curly braces.
Occasionally, you'll even see:
We obviously kill these things on sight.
Admin
This is not a WTF!
Long time ago, before the while loop existed, this was the available loop with scope.
for(;;) { // do stuff if (something) break; }
Admin
Someo I work with managed to figure out how to use reflection in Java to do a for loop.
Admin
Reminds me of code my former boss wrote (in PL/SQL):
for rec in cur loop <<lbl>> if (condition) goto lbl; ... end;
And then she complained that the database was too slow.
Admin
New emoticon? Why not Zoidberg?
(;;) {
Admin
Not a well-respected or especially feared super-villain, though. Pretty much limited to arching Encrypto and nobody knows what the hell that guy's talking about anyway.
(And how much do you love "Venture Brothers" for giving us this use of the word arching?)
Admin
Er, except, that's not what he's doing. Rather than putting the increment and terminating conditions of a counter in the for statement, he put it in the body, as if he was trying to implement a for loop in a while statement.
But, obviously you knew something so incredibly basic, and I'm obviously getting trolled. That's the preferable reality here.
Admin
Admin
Admin
I did this on one of my first professional projects. It started as try{ some stuff } catch(MyException ex){ some other stuff } catch(Exception ex){ a real error }
Not sure why I decided to do this, but it turned into about 10 different catch statements. I thought it was a fun way to do things. That software is gone now, so good riddance.
Admin
I comment out code all the time. It's usually because I'll want to use parts of it during the rewrite of the function, but I'm not sure what yet. I usually delete it after I'm done. Sometimes I forget.
Admin
Agreed. We have similar situations in our coding.
Admin
I actually giggled. Featured comment?
Admin
Real programmers do not giggle.
Admin
They do LOL instead.
Admin
Precisely. Perheps "heh" or even even "hehe". But not "lolol" (you're laughing out loud out loud? or is it laughing out laughing out loud?). Certainly never "lulz" or "lawlz".
Admin
(/)(;,,;)(/)
Admin
We need an 'edit' feature.
Admin
The link in the title is bad, it's relative and prompted me to download a-simple-misunderstanding.aspx
Admin
The first and last samples are just weird. I suspect the original programmers were just a bit... ...loopy.
Admin
I'll let that second point sink in for a bit.
Admin
Admin
YEAHHHHH!!!
Admin
Admin
Admin
The more ancient segments of the code base at work are littered with things like:
Of course, the language it's written in doesn't actually support while loops (well, not as while loops). Or curly braces.
Occasionally, you'll even see:
We obviously kill these things on sight.[/quote]
I'd be curious to see how you write assembler code without them.
Admin
Another fun fact about the same project: when I got to the project, every time it was called (which was every http request for a particular site), it took a statically-defined array of literal strings, iterated through that static array adding each element to a new List, then did a Contains on that List to see if the page was whitelisted. Why the original coder (who I have honestly no idea who it was; nobody actually in our office, I don't think) didn't just define a static List with the whitelist strings instead, I'm pretty baffled. (I know, iterating through a list of a dozen or so strings creating a new list takes basically 0 time compared to an actual http request, and premature optimization is the devil and stuff, but it was just so bafflingly -ugly-, I had to fix it.)
Admin
Admin
In the first example, the RWTF is not escaping the quotes in the echoed string, right? ;-)
Admin
The last one should happen in any untyped language with a for each construct.
Works in python, at least
Admin
Admin
Ugh. That has to be some kind of amateurish attempt at micro-optimization. That completely missed the mark.
Admin
Could this be an example of a poorly-done fix?
try { if (_staff == null) throw new NullReferenceException(); } catch (NullReferenceException) { _staff = _provider.GetStaff(); }
Perhaps the original just threw and later someone said to handle it and it was fixed by a moron.
Admin
Why wouldn't you put your conditional in the for statement? For that matter why not put your declaration and iteration in the for statement to?
Admin
Once again we're missing information to tell if the code is a real WTF or if it was valid given the date it was written, the language it was originally written in, the circumstances, well any sort of background.
Admin
Abusing the for construct to emulate a for loop is a wtf.
Admin
This is a syntax error...
In any case, TRWTF is having such a clunky for look in a "high-level" language in the first place.
While this is not a good way to program stuff, it's not one of those strange PHP quirks.
Python:
Ruby says:
Admin
Then you have two WTFs.
Admin
Admin
Admin
You start with one lame pun. Then you post it in a comment on TDWTF. Then you have two lame puns.
Something like that?