• 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?

  • Jimmy (unregistered)

    This is just plain sad :(

  • (cs)

    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.

  • erat (unregistered)

    You could use 3 = FNF == "FileNotFound" in a varchar2(5) !

  • I walked the dinosaur (unregistered)

    The real wtf is the bad attempt at linking to the cat with goggles picture from icanhascheezburger.

  • Velko (unregistered)

    I have seen something similar:

    select * from ZERO_ONE;
    
          NUMBER
    ============
               1
               0

    Column was INTEGER, so no place for FileNotFound neither.

  • Adriano (unregistered) in reply to gabba
    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.
  • Adriano (unregistered) in reply to Adriano
    Adriano:
    possibly to your arrays
    To array traversals, that is.
  • silent d (unregistered) in reply to erat
    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.

  • (cs) in reply to gabba
    gabba:
    You really ought to think twice on any design that involves thirteen months per year.
    Brr, lousy Smarch weather...
  • Anonymous (unregistered) in reply to Velko
    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

  • Michael (unregistered) in reply to ais523

    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

  • (cs) in reply to Velko
    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...

  • craig (unregistered)

    wow... I just shat my pants...

  • Adriano (unregistered) in reply to Michael

    As in

    states = ['on', 'off', 'burnt bulb', 'Arizona', 
    'New South Wales', 'contented', 'frolicking']

    ?

  • (cs)

    but which which is which and what what is which and where is the where?!

  • Corey (unregistered)

    Deep within the bowls ??

  • Greg (unregistered)

    What kind of bowls does this company have? Fruit bowls? Soup bowls? Enquiring minds want to know.

  • 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 :-)

  • Ace (unregistered) in reply to silent d

    Hmm. What about "!File"?

  • QuiMax (unregistered)

    Probably a student of "How to write unmaintainable code"

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

  • (cs) in reply to Velko
    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.

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

  • samwell (unregistered)

    what what, in the butt

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

  • Remember Lisa McPherson (unregistered) in reply to Olivier de Rivoyre
    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)

  • (cs)

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

  • (cs) in reply to Remember Lisa McPherson
    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...

  • SomeCoder (unregistered) in reply to Remember Lisa McPherson
    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.

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

  • radmike (unregistered) in reply to Corey

    Yeah, I was totally waiting for an awesome code story from a cereal factory.

  • morry (unregistered) in reply to ais523

    Sweet. A Y2.02K bug. Come back in 12 years as a HPC and fix it.

  • (cs)

    Good idea having 13 slots for months. Shows the coder was thinking ahead to future expansion. Scalable code... very enterprisy.

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

  • (cs)
    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?

  • (cs)

    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.

  • (cs) in reply to Izzy

    I thought I changed my name to "Bill Hirst." I gotta go check that.

  • No such file or directory (unregistered) in reply to ais523
    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...

  • 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)

  • FlyboyFred (unregistered) in reply to Greg
    Greg:
    What kind of bowls does this company have? Fruit bowls? Soup bowls? Enquiring minds want to know.

    Toilet bowls, perhaps?

  • Marchuary (unregistered) in reply to Anon Sam
    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?

  • fcardenas (unregistered) in reply to Architect Anonymous
    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';
    
  • 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.

  • Andrew (unregistered) in reply to Leo Davidson
    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]; }

  • James (unregistered) in reply to James
    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?

  • Andrew (unregistered) in reply to FredSaw
    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.

  • al (unregistered) in reply to Greg
    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.

  • Andrew (unregistered) in reply to al
    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.

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

Leave a comment on “I'll be back...”

Log In or post as a guest

Replying to comment #:

« Return to Article