- 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
I like how he divided the long string of zeroes into several smaller ones for readability.
Admin
Onehundredth!
Admin
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001th
Admin
0
Admin
Yeah, and he even politely added in differing length constant strings...
Admin
Oddly enough, we do the same thing at our company. At least Routing and Transit numbers are only 9 digits long...
Admin
Heh...we have to do this all the time in our app.
RIGHT('0000000...(one hundred zeros)' + userInput, 100)
Captcha: Valetudo Someone so smart they were Valedictorian and Salutatorian?
Admin
I like how the first parameter always calculates to zero.
Admin
It's performance optimisation
Admin
I hope this was computer-generated code.
Admin
I don't know which is the more entertaining wtf: allowing strings longer than 100 characters, or calling substring with an index of 0 and length equal to the string's total length.
Admin
Now that's a Maxi-Pad! And it appears to contain NO LEAKS.
Admin
Under the circumstances, that's a clever way to deal with it.
Admin
really clever indeed!
Admin
The rest of us were hoping no one would make that joke. Thanks, you've ruined the Internet for the rest of us, buddy.
Admin
He doesn't even validate that the data is a valid routing number.
Assuming the routing number is only supposed to have digits should be:
Admin
Especially since it has to run through all of the if-statements every single time. Why stop when you have your answer? Let's keep checking!
Admin
He obviously used TDD, and just made the tests pass, one by one.
Admin
Admin
Somebody's never heard of the switch statement.
CAPTCHA: "secundum" (not firstum)
Admin
I like the syntax highlighter. That's new, isn't it?
"Vale tudo" means something like "everything goes"/"everything's fair" in Portuguese.Admin
Why did he even bother to do the substring? It's always from 0 to length!
Admin
Pay per line FTW!
Admin
REPLICATE('0', 99 - CAST((LOG(userInput)/LOG(10)) AS int)) + CONVERT(varchar(100), userInput)
However, clever is a derogatory term in programming.
Admin
Clearly it should've been this...
var oneHundredZeroes = "0000....0000"; var length = Data.length;
return oneHundredZeroes.substring(100-length) + data;
/sarcasm
Admin
public String rateThisCode() { List<String> comment = new ArrayList<String>(); int length = 3;
while (comment.size()< length) { if (comment.size() == length-1) { comment.add("Fail"); } if (comment.size() == length-2) { comment.add("Than"); } if (comment.size() == length-3) { comment.add("Worse"); } } return comment.toString(); }
Admin
Yes - big kudos go out to Remy for suggesting and implementing.
Admin
Take it that's from SQL I think that's ok if you need to do it in DB.
Admin
Especially since the substrings are not a consistent length. Am I the only that actually counted? In case you haven't counted and wondered, the substring lengths are: 25, 17, 16, 16 25
Now that's just wrong!
Admin
And here I thought today had started out pretty well...
No bad traffic on the way to work, the latest software update build passed through QA with nary a hitch, no nasty-grams from clients or managers waiting in the inbox, then I read today's WTF...
and now I am filled with despair...
Admin
It is. I grabbed it from here.
Admin
"I have become death, destroyer of rather pleasant mornings."
Admin
why noat just add "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" as a suffix and then do a substring? :)
Admin
And using Java you would surely do something like
public String fill(String data) { return (data.length() > 100 ? data.substring(100) : data.length() = 99 ? "0" + data : data.length() = 98 ? "00" + data ... }
Admin
At least use "else if" for Christ's sake.
Admin
Awesome! It has a print feature, so I can print out TDWTF code! Now all I need is some matches...
Admin
Admin
That's called true zero. Clearly you can't trust the computer to provide true zero itself, you have to calculate it each time. Just in case. If you put a constant 0 in your code, who knows what the compiler will do with it?
Admin
It's easily understantable. That's the good part.
It gives me killing insticts. That's the bad part.
Admin
Wow, and amazingly it wasn't written in VB. I guess you can code poorly in other languages as well.
Admin
Any self-respecting computer would properly handle a length of 0.
Admin
That's a great WTF but my immediate thought on reading this article was that the real WTF is surely the fact that TDWTF has only just implemented syntax highlighting after all these years! Good job Remy, and welcome to the 21st century! Did you know they have talking picture boxes these days, too?
Admin
Breaking the 0's down into substrings means the coder was oh-so-close to a brilliant solution. What he should have done, of course, was to compute the length of the padding and then treat the length as a bit field. If the 1's digit is set, add "0". If the 2's digit is set, add "00". And so on. Much more scalable, don't you think? :-)
Admin
Fuck Christ, how about subsequent maintainers?
Admin
What I like about this one is that you just know one (at least) of those pads has the wrong number of zeros in it. Leading to a beautifully hard to diagnose intermittent error.
Admin
Yes, I did, but after I had already grabbed this and was getting it setup. I'll probably get it upgraded shortlyish.
All things considered, it's still a huge step up from pasting code into Pastie.org, viewing source, and copying the HTML. Which I've done. I've also got a Ruby script that generates HTML too.
This is much nicer.
Admin
string oneHundredZeros = new string('0', 100); return (oneHundredZeros + data).Substring(0, 100);
or better yet
return data.PadLeft(100, '0');
Admin
Like Buggz said, the "length-XX" as a first parameter to substring() makes it even more WTF-y.
Admin
A clever perl way:
$new_data = '0' x 100; $new_data++ until (!$data--);
Admin
I feel like this would have been better if he had gotten the Database involved somehow....