|
|
|
| Non-WTF Job: C++ Developer at Good Grievance (Ronkonkoma, NY) |
| « Prev | Page 1 | Page 2 | Next » |
|
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? |
|
This is just plain sad :(
|
|
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. |
|
You could use 3 = FNF == "FileNotFound" in a varchar2(5) !
|
|
The real wtf is the bad attempt at linking to the cat with goggles picture from icanhascheezburger.
|
|
I have seen something similar:
select * from ZERO_ONE; Column was INTEGER, so no place for FileNotFound neither. |
Re: I'll be back...
2008-04-21 09:40
•
by
Adriano
(unregistered)
|
Well, it's either that, and starting from 1 (notice month 0 wasn't named), or adding logic -possibly to your arrays- to compensate for the fact that most things think January is month 1 of the calendar. |
Re: I'll be back...
2008-04-21 09:41
•
by
Adriano
(unregistered)
|
To array traversals, that is. |
Re: I'll be back...
2008-04-21 09:44
•
by
silent d
(unregistered)
|
FNF is too cryptic, how about FnotF? (after all, we have 5 characters to use). That should make the code more readable. |
Brr, lousy Smarch weather... |
Re: I'll be back...
2008-04-21 09:48
•
by
Anonymous
(unregistered)
|
#define FileNotFound 2 |
Re: I'll be back...
2008-04-21 09:55
•
by
Michael
(unregistered)
|
|
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
|
We have a similar situation in our 3rd party issue registration software: select * from Yes_No Yes_No ------ 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... |
|
wow... I just shat my pants...
|
Re: I'll be back...
2008-04-21 10:00
•
by
Adriano
(unregistered)
|
|
As in
states = ['on', 'off', 'burnt bulb', 'Arizona', ? |
|
but which which is which and what what is which and where is the where?!
|
|
Deep within the *bowls* ??
|
|
What kind of bowls does this company have? Fruit bowls? Soup bowls? Enquiring minds want to know.
|
|
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 :-)
|
|
Hmm. What about "!File"?
|
|
Probably a student of "How to write unmaintainable code"
|
|
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.
|
No? How about 404 ;-) Bonus WTF then since the table is "ZERO_ONE" and contains a value that's neither zero nor one. |
|
Very good, but, Alex, can you filter a little the advertising in your site? I thinks that having "Imvu" or "scientology" advertises sucks...
|
|
what what, in the butt
|
|
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. |
Re: Advertising
2008-04-21 11:03
•
by
Remember Lisa McPherson
(unregistered)
|
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) |
|
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 ... |
Somehow I don't think Alex pays for bandwidth from an advertising website... |
Re: Advertising
2008-04-21 11:20
•
by
SomeCoder
(unregistered)
|
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. |
|
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. |
Re: I'll be back...
2008-04-21 11:46
•
by
radmike
(unregistered)
|
|
Yeah, I was totally waiting for an awesome code story from a cereal factory.
|
Re: I'll be back...
2008-04-21 11:46
•
by
morry
(unregistered)
|
|
Sweet. A Y2.02K bug. Come back in 12 years as a HPC and fix it.
|
|
Good idea having 13 slots for months. Shows the coder was thinking ahead to future expansion. Scalable code... very enterprisy.
|
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. |
I assume this lets it wait for more ports to open up, but what don't they have an idea about? |
|
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. |
|
I thought I changed my name to "Bill Hirst." I gotta go check that.
|
Re: I'll be back...
2008-04-21 12:52
•
by
No such file or directory
(unregistered)
|
Too bad the standard "ENOENT" (No such file or directory) is just a single character too wide. At least they left just enough space for "EBADF" (Bad file number), even though that's not exactly the same thing... |
|
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) |
Re: I'll be back...
2008-04-21 12:55
•
by
FlyboyFred
(unregistered)
|
Toilet bowls, perhaps? |
Re: I'll be back...
2008-04-21 13:08
•
by
Marchuary
(unregistered)
|
But these arrays will give you "Feb" as the abbreviation for March. Or am I missing something? |
Re: I'll be back...
2008-04-21 13:18
•
by
fcardenas
(unregistered)
|
if ((int_year > 80) && (int_year < 100)) int_year +=1900; if ((int_year >= 0) && (int_year < 20)) int_year +=2000; if ((int_year >= 20) && (int_year < 80)) onoff ='FNotF'; |
|
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. |
Re: I'll be back...
2008-04-21 13:22
•
by
Andrew
(unregistered)
|
Sorry my C is rusty: char[] getMonth(int value) { //TODO Limit checking if you really care return months[value - 1]; } |
Re: I'll be back...
2008-04-21 13:24
•
by
James
(unregistered)
|
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? |
Re: I'll be back...
2008-04-21 13:32
•
by
Andrew
(unregistered)
|
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. |
I dunno if "bowls" is the right word. I'm thinking, with this kind of code, he meant to say bongs. |
Re: I'll be back...
2008-04-21 13:36
•
by
Andrew
(unregistered)
|
That would be a party bowl then. |
|
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. |
| « Prev | Page 1 | Page 2 | Next » |