- 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 is a frist comment, which is a really good thing to have! // In case this is not returned bool isFirst= false; return isFirst.tostring()
Admin
My brain just melted and it's not because of the heatwave...
Admin
I think these comments are the least WTF part of the function. But they do provide useful insight as to just how WTF it is.
Admin
Strikes me as more of a child's game, or an early dev. learning project than having an actual real application.
Admin
As far as I can tell this entire function should:
In Java this can be done in one line: org.apache.commons.lang.StringUtils.containsAny(theword, "aeiou");
I assume that this is also the case in the language used.
Admin
in c# it'd be something like
var exists = myString.IndexOfAny(new []{'a','e','i','o','u'}) != -1;
Admin
I can't believe this is real
Admin
C# does allow that, but a break would be wholly redundant after a return.
Admin
Why, why, why, would you check on vowels in a word? I cannot think of a sane reason.
Anyone?
Admin
Admin
In ASCII land these implementations would somehow work. Ever dealt with code running on inputs from multiple locales? Similar to the "in my IDE more actions are linked to a hotkey than in yours" wars, where non US layout keyboard users end up in RSI hell.
Admin
It's good that extraBool2 is so handy and important that it's never referenced.
Admin
In C, one can (mis-)use strtok() to get the same effect:
It isn't what the function is meant for, but it will do the job. Seriously, how hard is that?
Admin
http://boardgames.about.com/od/scrabble/a/q_without_u.htm
Admin
I still can't believe that this is from a real business application. I'm almost sure that this comes from some programming class assignment. Or from a "programmer" who never made it past the CS-101 level.
Admin
Am I the only one that gets a headache when the comments run right into the code without whitespace
// this kind of comment makes my head hurt if (a == b) { ... } // This kind of comment I'm ok with since the } is // almost as good as whitespace but a=b; // got lost in the midst of the comments.
Admin
You will hear from PETA about that Labrador comment.
Admin
"Strikes me as more of a child's game, or an early dev. learning project than having an actual real application."
Ah, you mean 'organically grown' proprietary production code running 54% of all our businesses!
Admin
I've honestly met many Labrabors with better analytical skills than some of my colleagues so I take offense at this slight against Labradors.
(and... I don't belive this code can be real, there are some things that don't strike me as things an idiot would do, seems more like it is constructed to be WTF-y)
Admin
It will never go into this case anyway. One character is transformed to a string and the string is compared with "bcdfghjklmnprstvwxz" which is always false.
Captcha: CAPIO - This comment was provided by Capio Obvious
Admin
..and it wouldn't matter anyway because any character other than a, e, i, o, u and y will do this:
Admin
...unless the parameter value passed was null, in which case it would throw an exception on the very first "if" statement.
Admin
Only 54%? We should consider ourselves very lucky.
Admin
If seen stuff like this when the developer is trying to determine if an input contains actual words or just random crap. This follows the logical fallacy: 'All words have at least one vowel; therefor any text that contains a vowel must be a word'.
Admin
We just had a guy come (and go) that wouldn't even have been able to produce this.
This is what happens when you let the suits handle recruiting.
Admin
I went down to the cwm and played my crwth, but I heard the howling of the Cwn Annwn!
http://dictionary.reference.com/help/faq/language/t50.html
Admin
"Invalid password. Your password must contain at least 1 lowercase letter, 1 uppercase letter, 2 numbers, 5 symbols, 1 vowel, and your first born child.
Admin
So, according to this bulletproof code, "And" does not contain a vowel. Neither dos "The", since it doesn't search past the first letter.
If you're going to return a boolean with a .ToString(), then I think you should at least do it up right:
HasAVowel("fubar") should return "true", and HasAVowel("FUBAR") should return "TRUE"
Admin
Admin
Wow, I've seen some bad code in my time, but I struggle to believe this is the output of a professional developer.
Admin
Could be a wheel of fortune thing?
Admin
Admin
Nope, try Qat, yes it is a word.
Admin
Why do so many of you think it only looks at the first char in the string? Did you miss the 'foreach' ?
Admin
TRWTF is all the ToString() calls on string literals.
Admin
Admin
Admin
Did you miss the 'return' in each case?
Admin
missed the quote button
Admin
I hope you're trolling.
If you're that thick, note that the "loop" always returns during the first iteration due to the default case.
Admin
Now I'm imagining this as Python code with yield everywhere instead of return.
Admin
Vowels...so I noticed it doesn't check for cases where 'y' behaves as a vowel, and assumes the English language.
If they were clever then they'd check the locale and pull in the list of vowels and exceptional cases from some database...I guess with the following schema
language : varchar(200), aisvowel : boolean, eisvowel : boolean . . .
;-)
Admin
Maybe then we should use the Null2 function so it won't crash all the time ?
Admin
So "crwth" has no vowel in it?
Admin
T nsrs y dn't mk ths knd f mstk?
Admin
Admin
Both of you geniuses failed to handle the use of y as a vowel.
Admin
There are 3 logic errors in HasAVowel. And I consider proper line spacing as important as good comments. Still better than most code out there though.
Admin
I see the real WTF: he missed the most important one!
Much better!
Admin
Also that you can't use quote to quote people that weren't in the thread here, unlike every other commenting system ever. >.>