Comment On I'll be back...

Originally posted by "JukeboxJim" ... [expand full text]
« PrevPage 1 | Page 2Next »

Re: I'll be back...

2008-04-21 09:09 • by ais523 (unregistered)
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?

Re: I'll be back...

2008-04-21 09:09 • by Jimmy (unregistered)
This is just plain sad :(

Re: I'll be back...

2008-04-21 09:14 • by gabba
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.

Re: I'll be back...

2008-04-21 09:19 • by erat (unregistered)
You could use 3 = FNF == "FileNotFound" in a varchar2(5) !

Re: I'll be back...

2008-04-21 09:23 • by I walked the dinosaur (unregistered)
The real wtf is the bad attempt at linking to the cat with goggles picture from icanhascheezburger.

Re: I'll be back...

2008-04-21 09:30 • by Velko (unregistered)
I have seen something similar:
select * from ZERO_ONE;


NUMBER
============
1
0

Column was INTEGER, so no place for FileNotFound neither.

Re: I'll be back...

2008-04-21 09:40 • by Adriano (unregistered)
190705 in reply to 190694
gabba:
You really ought to think twice on any design that involves thirteen months per year

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)
190706 in reply to 190705
Adriano:
possibly to your arrays

To array traversals, that is.

Re: I'll be back...

2008-04-21 09:44 • by silent d (unregistered)
190707 in reply to 190697
erat:
You could use 3 = FNF == "FileNotFound" in a varchar2(5) !


FNF is too cryptic, how about FnotF? (after all, we have 5 characters to use). That should make the code more readable.

Re: I'll be back...

2008-04-21 09:45 • by Andy Goth
190708 in reply to 190694
gabba:
You really ought to think twice on any design that involves thirteen months per year.
Brr, lousy Smarch weather...

Re: I'll be back...

2008-04-21 09:48 • by Anonymous (unregistered)
190710 in reply to 190703
Velko:
I have seen something similar:
select * from ZERO_ONE;


NUMBER
============
1
0

Column was INTEGER, so no place for FileNotFound neither.

#define FileNotFound 2

Re: I'll be back...

2008-04-21 09:55 • by Michael (unregistered)
190711 in reply to 190691
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

Re: I'll be back...

2008-04-21 09:59 • by MetalPig
190712 in reply to 190703
Velko:
I have seen something similar:
select * from ZERO_ONE;


NUMBER
============
1
0

Column was INTEGER, so no place for FileNotFound neither.

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...

Re: I'll be back...

2008-04-21 09:59 • by craig (unregistered)
wow... I just shat my pants...

Re: I'll be back...

2008-04-21 10:00 • by Adriano (unregistered)
190714 in reply to 190711
As in
states = ['on', 'off', 'burnt bulb', 'Arizona', 

'New South Wales', 'contented', 'frolicking']

?

Re: I'll be back...

2008-04-21 10:08 • by Pol
but which which is which and what what is which and where is the where?!

Re: I'll be back...

2008-04-21 10:10 • by Corey (unregistered)
Deep within the *bowls* ??

Re: I'll be back...

2008-04-21 10:10 • by Greg (unregistered)
What kind of bowls does this company have? Fruit bowls? Soup bowls? Enquiring minds want to know.

Re: I'll be back...

2008-04-21 10:11 • by Tom M (unregistered)
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 :-)

Re: I'll be back...

2008-04-21 10:17 • by Ace (unregistered)
190722 in reply to 190707
Hmm. What about "!File"?

Re: I'll be back...

2008-04-21 10:18 • by QuiMax (unregistered)
Probably a student of "How to write unmaintainable code"

Re: I'll be back...

2008-04-21 10:21 • by Ru (unregistered)
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.

Re: I'll be back...

2008-04-21 10:24 • by ObiWayneKenobi
190725 in reply to 190703
Velko:
I have seen something similar:
select * from ZERO_ONE;


NUMBER
============
1
0

Column was INTEGER, so no place for FileNotFound neither.


No? How about 404 ;-) Bonus WTF then since the table is "ZERO_ONE" and contains a value that's neither zero nor one.

Advertising

2008-04-21 10:29 • by Olivier de Rivoyre (unregistered)
Very good, but, Alex, can you filter a little the advertising in your site? I thinks that having "Imvu" or "scientology" advertises sucks...

Re: I'll be back...

2008-04-21 10:37 • by samwell (unregistered)
what what, in the butt

Re: I'll be back...

2008-04-21 11:02 • by Architect Anonymous (unregistered)
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)
190732 in reply to 190726
Olivier de Rivoyre:
Very good, but, Alex, can you filter a little the advertising in your site? I thinks that having "Imvu" or "scientology" advertises sucks...


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)

Re: I'll be back...

2008-04-21 11:11 • by ParkinT
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 ...

Re: Advertising

2008-04-21 11:16 • by Otterdam
190736 in reply to 190732
Remember Lisa McPherson:
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)


Somehow I don't think Alex pays for bandwidth from an advertising website...

Re: Advertising

2008-04-21 11:20 • by SomeCoder (unregistered)
190737 in reply to 190732
Remember Lisa McPherson:

If you've got Firefox, use the AdBlock Plus plugin; it saves Alex's bandwidth for ads you don't want to see.



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.

Re: I'll be back...

2008-04-21 11:37 • by Leo Davidson (unregistered)
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)
190742 in reply to 190717
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)
190743 in reply to 190691
Sweet. A Y2.02K bug. Come back in 12 years as a HPC and fix it.

Re: I'll be back...

2008-04-21 12:05 • by FredSaw
Good idea having 13 slots for months. Shows the coder was thinking ahead to future expansion. Scalable code... very enterprisy.

Re: I'll be back...

2008-04-21 12:27 • by Anon Sam (unregistered)

static char months[13][4] = {
" ", "Jan", "Feb", "Mar", "Apr", "May",
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
static char monthslow[13][4] = {
" ", "jan", "feb", "mar", "apr", "may",
"jun", "jul", "aug", "sep", "oct", "nov", "dec"};

...

if ((int_year > 80) && (int_year < 100)) int_year +=1900;
if ((int_year >= 0) && (int_year < 20)) int_year +=2000;


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.

Re: I'll be back...

2008-04-21 12:31 • by bryan986

SLEEP(func, 5, "No idea");


I assume this lets it wait for more ports to open up, but what don't they have an idea about?

Re: I'll be back...

2008-04-21 12:35 • by Izzy
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.

Re: I'll be back...

2008-04-21 12:36 • by Izzy
190753 in reply to 190752
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)
190754 in reply to 190691
ais523:
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?
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...

Re: I'll be back...

2008-04-21 12:53 • by YAYitsAndrew (unregistered)
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)
190756 in reply to 190718
Greg:
What kind of bowls does this company have? Fruit bowls? Soup bowls? Enquiring minds want to know.


Toilet bowls, perhaps?

Re: I'll be back...

2008-04-21 13:08 • by Marchuary (unregistered)
190758 in reply to 190749
Anon Sam:
static char months[13][4] = {
" ", "Jan", "Feb", "Mar", "Apr", "May",
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
static char monthslow[13][4] = {
" ", "jan", "feb", "mar", "apr", "may",
"jun", "jul", "aug", "sep", "oct", "nov", "dec"};


These are both fine. The third month is "Mar" not "Apr".
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)
190759 in reply to 190731
Architect Anonymous:
if ((int_year > 80) && (int_year < 100)) int_year +=1900;
if ((int_year >= 0) && (int_year < 20)) int_year +=2000;



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';

Re: I'll be back...

2008-04-21 13:20 • by James (unregistered)
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)
190761 in reply to 190741
Leo Davidson:
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.


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)
190762 in reply to 190760
James:

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.


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)
190763 in reply to 190747
FredSaw:
Good idea having 13 slots for months. Shows the coder was thinking ahead to future expansion. Scalable code... very enterprisy.


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.

Re: I'll be back...

2008-04-21 13:32 • by al (unregistered)
190764 in reply to 190718
Greg:
What kind of bowls does this company have? Fruit bowls? Soup bowls? Enquiring minds want to know.


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)
190765 in reply to 190764
al:
Greg:
What kind of bowls does this company have? Fruit bowls? Soup bowls? Enquiring minds want to know.


I dunno if "bowls" is the right word. I'm thinking, with this kind of code, he meant to say bongs.


That would be a party bowl then.

Re: I'll be back...

2008-04-21 13:43 • by Jason (unregistered)
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.
« PrevPage 1 | Page 2Next »

Add Comment