- 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
Too bad the "text" column is only a VARCHAR2(5).
No, that's only what it is at the moment. Presumably, if there was a need to add FILE_NOT_FOUND at a later date, the application would automatically ALTER the TABLE to make it a wider column. After all, why waste space with wide columns, when you can automatically resize them to fit the data?
Admin
This is just plain sad :(
Admin
Question: why did you snip the code from block C? I'd like to find out how X became the tenth letter of the alphabet.
Gotta love the 'other gems'. You really ought to think twice on any design that involves thirteen months per year. And if they're going to insist on using two digits for the year, at least cover all 100 values.
Admin
You could use 3 = FNF == "FileNotFound" in a varchar2(5) !
Admin
The real wtf is the bad attempt at linking to the cat with goggles picture from icanhascheezburger.
Admin
I have seen something similar:
Column was INTEGER, so no place for FileNotFound neither.
Admin
Admin
Admin
FNF is too cryptic, how about FnotF? (after all, we have 5 characters to use). That should make the code more readable.
Admin
Admin
Admin
As for on/off, maybe it's a bad idea, but when there will be more states, it would be better to use such table instead of "magic" numbers
Admin
No Yes
I have the privileges to change it (all users do; there are many WTFs here), but I haven't had the guts. Field length is 5, so there's no room to do fun stuff like 'Hell yeah!' and 'No way!', but adding 'Fnf' is an option...
Admin
wow... I just shat my pants...
Admin
As in
?
Admin
but which which is which and what what is which and where is the where?!
Admin
Deep within the bowls ??
Admin
What kind of bowls does this company have? Fruit bowls? Soup bowls? Enquiring minds want to know.
Admin
Even a width of 5 is too much and just occupying precious space, the longest string used counts 3 characters.. So I read that last sentence as a sarcastic comment, this system is indeed very weird :-)
Admin
Hmm. What about "!File"?
Admin
Probably a student of "How to write unmaintainable code"
Admin
13 months eh? I can see the point of that, seeing as how months of the year are inconveniently indexed from 1 in real world dates.
Admin
No? How about 404 ;-) Bonus WTF then since the table is "ZERO_ONE" and contains a value that's neither zero nor one.
Admin
Very good, but, Alex, can you filter a little the advertising in your site? I thinks that having "Imvu" or "scientology" advertises sucks...
Admin
what what, in the butt
Admin
if ((int_year > 80) && (int_year < 100)) int_year +=1900; if ((int_year >= 0) && (int_year < 20)) int_year +=2000;
This looks like a workaround for Javascript's buggy support for dates. Not really the authors fault.
Admin
If you've got Firefox, use the AdBlock Plus plugin; it saves Alex's bandwidth for ads you don't want to see.
That said, I am disappointed to hear that this site accepts ad money from Scientology. (Please visit whyaretheydead.net)
Admin
One obvious ommission is: static char monthsvaried[13][5] = { " ", "jAn", "fEb", "mAr", "aPr", "mAy", "jUn", "jUl", "aUg", "sEp", "oCt", "nOv", "dEc"}; static char monthvaried[13][6] = { " ", "jaN", "feB", "maR", "apR", "maY", "juN", "juL", "auG", "seP", "ocT", "noV", "deC"}; static char monthsvaried[13][7] = { " ", "JAn", "FEb", "MAr", "APr", "MAy", "JUn", "JUl", "AUg", "SEp", "OCt", "NOv", "DEc"}; ... snip ...
Admin
Somehow I don't think Alex pays for bandwidth from an advertising website...
Admin
Off topic but is that how AdBlock works? Does it actually not download the offending material or does it download it but not display it?
I'm just curious. I use AdBlock and I love it.
Admin
Maybe I'm missing something but I don't see anything wrong with the two arrays of month names.
I presume that the mixed-case one is used for presentation (those are the month names displayed to the user) while the lower-case one is used for comparison with other strings which have already been converted to lower-case. It's much faster to lower-case a string once and then do case-sensitive compare on it to a number of other strings than it is to do a case-insensitive compare every time.
(You could argue that the code shouldn't be walking an array doing string comparisons, but with only 12 items to compare -- the 0th being skipped -- I doubt other data structures would make much difference, especially if they're not provided by whatever framework was in use.)
As others have said, making the array start with a dummy month allows you to index it using 1-based month numbers like, well, the entire rest of the world. That is completely standard and I've seen it in a lot of code and text books.
The rest of the code does seem pretty WTF-worthy, though.
Admin
Yeah, I was totally waiting for an awesome code story from a cereal factory.
Admin
Sweet. A Y2.02K bug. Come back in 12 years as a HPC and fix it.
Admin
Good idea having 13 slots for months. Shows the coder was thinking ahead to future expansion. Scalable code... very enterprisy.
Admin
These are both fine. The third month is "Mar" not "Apr".
And if someone is using two-digit years, they need to be corrected. It would be nice if the system warned them that their inputs were being auto-corrected, and sometimes it's good to not be liberal in what you accept. But it's not WTF-worthy.
Admin
I assume this lets it wait for more ports to open up, but what don't they have an idea about?
Admin
There's nothing wrong with a 13 month table. It lets you handle end-of-year wrap-around and returns Jan as the 13'th month. At least it doesn't crash on an index overflow on December 31 + one day.
Yeah, you still need to adjust the calling routine to get the right year, but sometimes that's easier.
Just put in lots of comments to show any any future maintence people what you did, what you were trying to do, and why you did it.
Extra comments never hurt.
Admin
I thought I changed my name to "Bill Hirst." I gotta go check that.
Admin
At least they left just enough space for "EBADF" (Bad file number), even though that's not exactly the same thing...
Admin
I wish this was posted under Code SOD so that I would have known to avoid it. I don't enjoy reading other people's terrible code.
captcha: minim (as in 'minim'um effort Alex has been putting into these past few updates)
Admin
Toilet bowls, perhaps?
Admin
Admin
Admin
I'm guessing the existence of the Yes/No - Zero/One tables are because the guy knows how to use foreign keys, but does not know how to use constraints -- or maybe the DB he was using doesn't support constraints.
This way, he can basically make a new enumerated column type that the database will enforce at runtime. I'm not saying it's a good idea, but it looks like he was doing the best he could with the tools he had.
I have just enough SQL knowledge to be dangerous, which is probably bad since I'm designing a database for a big project now. In SQL Server 2005, there's no "boolean" column type, so I just use an int and interpret the values 0 and 1 as false and true respectively. Would it be "better" to have a tblTrueFalse:
ID VALUE 0 FALSE 1 TRUE
then set up a foreign key so that trying to modify a record with a value of 2 would throw an error immediately? I don't plan to do it, but it's one of the only solutions I would be able to come up with give my (admittedly lacking) knowledge of the system.
Admin
Sorry my C is rusty:
char[] getMonth(int value) { //TODO Limit checking if you really care return months[value - 1]; }
Admin
Wow, I feel like an idiot -- 10 seconds of Googling turned up the Bit data type. D'oh! Anyway, the idea still applies (of using a foreign-keyed table to make your own enumerated data type), just where there's more than two (but fewer than 10/26/whatever) valid choices. Is that a terrible idea, or what?
Admin
Yeah, but that's until they decide that Feb isn't a real month. Its number of days change and its too small to be a real month. We therefore now refer to it at a dwarf month.
Admin
I dunno if "bowls" is the right word. I'm thinking, with this kind of code, he meant to say bongs.
Admin
That would be a party bowl then.
Admin
Can someone explain to me what the WTF is with the network code?
I'm not sure what this TIMEDWAIT thing is he's talking about and a quick google search didn't reveal it to me in under 27 seconds.