• Ozz (unregistered) in reply to derp
    derp:
    private static int convertDate(int day, int month, int year)
    {
    

    int[] months = new int[] { 0,31,59,90,120,151, 181,212,243,273,304,334 };

    return ( ((year - 1970) * DAY * 365) + (((year - 1970)/4) * DAY) + (months[month - 1] * DAY) + ((day-1) * DAY) ); }

    TRWTF is the ridiculous formatting. Why Must every thing get its own line

    S o m e

    c o d e r s

    a r e

    p a i d

    b y

    t h e

    l i n e .

  • (cs) in reply to Anon
    Anon:
    We don't all have fancy wide- screen monitors you insensitive clod!
    Does your 3 inch monitor have a scroll bar?
  • Anon (unregistered) in reply to PiisAWheeL
    PiisAWheeL:
    Anon:
    We don't all have fancy wide- screen monitors you insensitive clod!
    Does your 3 inch monitor have a scroll bar?

    Hey! Your mom didn't have any problems monitoring my 3 inches with her scroll bar.

  • ike (unregistered) in reply to ObiWayneKenobi

    The customer is always right. Not everyone is a customer, that's all :)

  • (cs) in reply to Anon
    Anon:
    PiisAWheeL:
    Anon:
    We don't all have fancy wide- screen monitors you insensitive clod!
    Does your 3 inch monitor have a scroll bar?

    Hey! Your mom didn't have any problems monitoring my 3 inches with her scroll bar.

    Wow dude... you have just taken offense to everything i've said, and you are taking all of it way too seriously. Do they not have medical marijuana where you live yet? If I was a doctor I would prescribe you some for stress. It looks like you really need it.

  • (cs) in reply to ike
    ike:
    The customer *is* always right.
    They may be unreasonable, ignorant, clueless, stubborn, unrealistic, foolish, short-sighted and/or idiotic, but they are always right!
  • Hmmmm (unregistered) in reply to snoofle
    snoofle:
    ike:
    The customer *is* always right.
    They may be unreasonable, ignorant, clueless, stubborn, unrealistic, foolish, short-sighted, idiotic and/or completely wrong, but they are always right!
    FTFY
  • Calli Arcale (unregistered)

    Oh, fun. I've also dealt with people who think that it's only a defect if it makes the product violate specs. Anything else is an enhancement. Apparently "functioning" isn't considered an implicit design spec....

    That said, if this doesn't violate a spec, then the specs aren't as extensive as they're claiming, since this function will not work as advertised. Or working correctly is considered an optional extra.

  • Herr Otto Flick (unregistered) in reply to Brian E
    Brian E:
    Sure, let's make something that will break on January 19, 2038. http://en.wikipedia.org/wiki/Year_2038_problem

    This is the second person to claim this. First off, its nonsense. The problem will happen much sooner, as they are using int (31 bits), and not unsigned int (32 bits).

    Secondly, there is only a year 2038 problem if you are using int as your time type. All real OS have time_t type, which is/will be at least 64bit by 2038, if it isn't already.

    Finally, there is not enough context for determining whether this is a WTF or not. If the only goal of the code is to say how many days ago a request was opened, and requests are never opened longer than a year, then this may be 'good enough'.

    You might want to consider why some developers are doing 2nd line support and maintenance, and why some are designing and specifying the project.

    TRWTF would be a junior developer seeing something minor and jumping all over it like a pre-teen on Bieber, and then bitching on the internet when his wailing is deemed irrelevant.

  • Herr Otto Flick (unregistered) in reply to derp
    derp:
    private static int convertDate(int day, int month, int year)
    {
    

    int[] months = new int[] { 0,31,59,90,120,151, 181,212,243,273,304,334 };

    return ( ((year - 1970) * DAY * 365) + (((year - 1970)/4) * DAY) + (months[month - 1] * DAY) + ((day-1) * DAY) ); }

    TRWTF is the ridiculous formatting. Why Must every thing get its own line

    78 characters or less, bitch.

    TBH, this isn't really even formatting. This is just what you get when you set up vim right, and just type C style code.

  • LANMind (unregistered) in reply to Herr Otto Flick
    Herr Otto Flick:
    TRWTF would be a junior developer seeing something minor and jumping all over it like a pre-teen on Bieber, and then bitching on the internet when his wailing is deemed irrelevant.

    Welcome to teh interwebs!

  • Ralph (unregistered) in reply to Bruce W
    Bruce W:
    I just finished a product that was so focused on the front end working that several key backend processes were forgotten all together. But, hey, the front end was pretty and worked "right".
    If the front end is pretty enough, it doesn't have to work "right" or even at all. MS proved this decades ago.

    This is because most people have a fundamental inability to evaluate software quality. So they assume "wow if they put that much work into making it look so good, it must be good."

  • djeidot (unregistered) in reply to ObiWayneKenobi
    ObiWayneKenobi:
    ParkinT:
    "If it ain't broke, don't fix it" So much for Code Excellence!

    I DESPISE that quote and the associated mentality with the fire of a thousand suns. Something can be "broke" and still appear to be working properly; doesn't mean it isn't broken and should be ignored.

    This mentality is the reason there is so much shitty software out there (and the reason this site exists) because people are so reluctant to mercilessly refactor code and follow good craftsmanship principles under this false pretense.

    The greatest lie in business is "The customer is always right". The second is "If it ain't broke, don't fix it".

    I honestly think that the "If it ain't broke, don't fix it" quote is absolutely right.

    But it should be followed by Seth Godin's quote: "If you think it's broken, then it's broken".

  • just me (unregistered) in reply to djeidot
    djeidot:
    ObiWayneKenobi:
    ParkinT:
    "If it ain't broke, don't fix it" So much for Code Excellence!

    I DESPISE that quote and the associated mentality with the fire of a thousand suns. Something can be "broke" and still appear to be working properly; doesn't mean it isn't broken and should be ignored.

    This mentality is the reason there is so much shitty software out there (and the reason this site exists) because people are so reluctant to mercilessly refactor code and follow good craftsmanship principles under this false pretense.

    The greatest lie in business is "The customer is always right". The second is "If it ain't broke, don't fix it".

    I honestly think that the "If it ain't broke, don't fix it" quote is absolutely right.

    But it should be followed by Bob Dylan's quote: "Everything is broken".

    FTFY

  • (cs)

    "If it ain't broke, fix it until it is."

  • (cs) in reply to Zylon

    A bicycle repair shop when I was kid had a sign that read:

    "If we can't fix it we'll fix it so nobody can!"

  • Nagesh (unregistered) in reply to Zylon
    Zylon:
    "If it ain't broke, fix it until it is."
    What meaning is "ain't"?
  • dogmatic (unregistered) in reply to ObiWayneKenobi

    Unfortunately in the real world there are things like "deadlines" which have to be met. Every developer should keep in mind that, when looking at another's code, they will always find things that look ugly to them, that they would do another way.

  • (cs) in reply to Herr Otto Flick
    Herr Otto Flick:
    Brian E:
    Sure, let's make something that will break on January 19, 2038. http://en.wikipedia.org/wiki/Year_2038_problem

    This is the second person to claim this. First off, its nonsense. The problem will happen much sooner, as they are using int (31 bits), and not unsigned int (32 bits).

    No, that's when the “end of time”(_t) happens if it is a 32-bit signed integer; it's 2**31 seconds after the start of 1970. Unsigned would give another 68 or so years, but would have stopped early Unix systems from referring to dates before 1970 (a more pressing need at the time that the time system was developed).

    Of course, there's no actual need for there to be a problem at all, provided the size of time_t itself is expanded (1970 AD+2**63 seconds is a very long time off indeed). The real issue is going to be migrating all the existing data, notably including filesystems and archives of various kinds. The lifespan of builds of programs is much shorter than that of data.

  • anon (unregistered) in reply to Ralph
    Ralph:
    Bruce W:
    I just finished a product that was so focused on the front end working that several key backend processes were forgotten all together. But, hey, the front end was pretty and worked "right".
    If the front end is pretty enough, it doesn't have to work "right" or even at all. MS proved this decades ago.

    This is because most people have a fundamental inability to evaluate software quality. So they assume "wow if they put that much work into making it look so good, it must be good."

    Turns out, this applies to construction as well. I've seen plenty of stuff in my home that looks great on the surface, but if you peel back the covers a bit, it's just a mess. Former owners hired some real winners to do upgrades.

  • gr[a/e]y goat (unregistered) in reply to Ralph
    Ralph:
    Bruce W:
    I just finished a product that was so focused on the front end working that several key backend processes were forgotten all together. But, hey, the front end was pretty and worked "right".
    If the front end is pretty enough, it doesn't have to work "right" or even at all. MS proved this decades ago.

    This is because most people have a fundamental inability to evaluate software quality. So they assume "wow if they put that much work into making it look so good, it must be good."

    Wait, have Microsoft and "looks pretty" ever really gone together?

  • Z (unregistered)

    TRWTF is expecting outsourced code to work correctly in the first place. Face it, you are working with a bunch of Indian code monkeys who are 'coding to the spec', and who will freely mash whatever unholy code style and practice they are familiar with into your shiny new project, because that is what they know.

    At my company, we are still maintaining an outsourced program I like to refer to as the 'Indian abomination'. After we got the final code drop, it took me another 9 months to get it into working shape, and we still find hidden gems that make us go 'huh?' every once in a while.

  • Nagesh (unregistered) in reply to Z
    Z:
    TRWTF is expecting outsourced code to work correctly in the first place. Face it, you are working with a bunch of Indian code monkeys who are 'coding to the spec', and who will freely mash whatever unholy code style and practice they are familiar with into your shiny new project, because that is what they know.

    At my company, we are still maintaining an outsourced program I like to refer to as the 'Indian abomination'. After we got the final code drop, it took me another 9 months to get it into working shape, and we still find hidden gems that make us go 'huh?' every once in a while.

    Like any programer, Indian is not mind-reader. All we can code 4 is what customer ask for.
  • qwerty (unregistered) in reply to Nagesh
    Nagesh:
    This aproach is prefered. Simpler to be converting to C for linux app (much quiker performing) or any system without suport library function. Time function is wel-defined already: why convert to langage-specific fuctions for no benefit?

    Everyone ignore this guy... low level troll here.

  • Anon (unregistered) in reply to dogmatic
    dogmatic:
    Unfortunately in the real world there are things like "deadlines" which have to be met. Every developer should keep in mind that, when looking at another's code, they will always find things that look ugly to them, that they would do another way.

    A good point...except they actually did it the long-winded way instead of using the built-in functionality.

  • Brent (unregistered)

    TRWTF is that Jeff took ten minutes figuring this code out. It's obviously trying to calculate time since Unix epoch... it's also immediately obvious that it's buggy because the line (which is nicely separated out from the rest of the calculation for clarity) for handling leap years is based off a year that's not divisible by four (in addition to the lack of support for 2100).

  • Nagesh (unregistered) in reply to qwerty
    qwerty:
    Nagesh:
    This aproach is prefered. Simpler to be converting to C for linux app (much quiker performing) or any system without suport library function. Time function is wel-defined already: why convert to langage-specific fuctions for no benefit?

    Everyone ignore this guy... low level troll here.

    Al I say is true, masterchord!!!

  • Jack (unregistered) in reply to Herr Otto Flick
    Herr Otto Flick:
    Finally, there is not enough context for determining whether this is a WTF or not. If the only goal of the code is to say how many days ago a request was opened, and requests are never opened longer than a year, then this may be 'good enough'.

    Actually, there is plenty of context to determine it is a WTF.

    First of all, there are built-in functions that do this right.

    Second, the request doesn't have to be open for over a year for the bug to show up. Try February 28, 2012 to March 1, 2012.

  • khermitt (unregistered) in reply to Nagesh
    Nagesh:
    Zylon:
    "If it ain't broke, fix it until it is."
    What meaning is "ain't"?
    I'ts a variable tah't holds only rationalnumbers
  • (cs) in reply to Jack
    Jack:
    Actually, there is plenty of context to determine it is a WTF.

    First of all, there are built-in functions that do this right.

    Second, the request doesn't have to be open for over a year for the bug to show up. Try February 28, 2012 to March 1, 2012.

    OK, I will.

    int intDay1 = 1; 
    int intMonth1 = 3; 
    int intYr1 = 2012;
    
    int intDay2 = 28;
    int intMonth2 = 2; 
    int intYr2 = 2012;
    
    int strElapsedDays = (
        convertDate(intDay1, intMonth1, intYr1) -
        convertDate(intDay2, intMonth2, intYr2)) / DAY;
    
    Console.WriteLine(String.Format("convertDate diff: {0}", 
        strElapsedDays));
    
    
    TimeSpan diff = new DateTime(intYr1, intMonth1, intDay1) 
        - new DateTime(intYr2, intMonth2, intDay2);
    int daysDiff = diff.Days;
    
    Console.WriteLine(String.Format("TimeSpan diff: {0}", 
        daysDiff));
    

    convertDate diff: 1 TimeSpan diff: 2

    Oh, it's off by a day. Go figure.

    The worst part is that you know that this is just the tip of the iceberg. They've probably written dozens of other buggy, poorly-documented date-handling routines for validation, converting from strings, or determining the day of the week.

  • sbs (unregistered) in reply to Nagesh

    "ain't" is a contraction of "am not" and "have not" -- see http://en.wikipedia.org/wiki/Ain't

    People use "ain't" also as a contraction of "is not" and "are not" "It ain't going to work" == "It is not going to work" "If it ain't broke, don't fix it" == "If the object or system operates satisfactorily, do not attempt to improve it in some irrelevant manner that may make things worse."

    In most of the United States, "ain't" is considered incorrect, and its use marks the speaker as being ignorant or uneducated. In some areas and within some groups, it is an acceptable usage, especially when speaking informally (say "ain't" to your friends, but not to the judge at your trial.)

    In "if it ain't broke, don't fix it" the speaker is using "ain't" and "broke" ("broken" is the standard usage) to suggest the point of view of a person who may not be highly educated, but has practical knowledge and wisdom that are more valuable than formal education, especially formal education without real-world experience. The speaker may be advising you to look for a higher-priority project to work on. Or, he may judge that the object or system that "ain't broke" is actually more complex than you can manage, and doesn't want to you to break it even more while trying to fix it.

    Of course, you still have to decide for yourself whether the person is actually saying something wise, or is just repeating an old saying. (The wikipedia article gives more info on "if it ain't broke, don't fix it.")

  • (cs)

    WhoTF is sbs talking to?

  • Nagesh (unregistered) in reply to sbs
    sbs:
    "ain't" is a contraction of "am not" and "have not" -- see http://en.wikipedia.org/wiki/Ain't

    People use "ain't" also as a contraction of "is not" and "are not" "It ain't going to work" == "It is not going to work" "If it ain't broke, don't fix it" == "If the object or system operates satisfactorily, do not attempt to improve it in some irrelevant manner that may make things worse."

    In most of the United States, "ain't" is considered incorrect, and its use marks the speaker as being ignorant or uneducated. In some areas and within some groups, it is an acceptable usage, especially when speaking informally (say "ain't" to your friends, but not to the judge at your trial.)

    In "if it ain't broke, don't fix it" the speaker is using "ain't" and "broke" ("broken" is the standard usage) to suggest the point of view of a person who may not be highly educated, but has practical knowledge and wisdom that are more valuable than formal education, especially formal education without real-world experience. The speaker may be advising you to look for a higher-priority project to work on. Or, he may judge that the object or system that "ain't broke" is actually more complex than you can manage, and doesn't want to you to break it even more while trying to fix it.

    Of course, you still have to decide for yourself whether the person is actually saying something wise, or is just repeating an old saying. (The wikipedia article gives more info on "if it ain't broke, don't fix it.")

    Thank you kindly! I ain't will be forgeting this explaination!

  • Jazz (unregistered) in reply to Nagesh
    Nagesh:
    This aproach is prefered. Simpler to be converting to C for linux app (much quiker performing) or any system without suport library function. Time function is wel-defined already: why convert to langage-specific fuctions for no benefit?

    Does anyone know if this guy is for real or a troll? He posts things like this on nearly every post thread.

  • (cs) in reply to Jazz
    Jazz:
    Nagesh:
    This aproach is prefered. Simpler to be converting to C for linux app (much quiker performing) or any system without suport library function. Time function is wel-defined already: why convert to langage-specific fuctions for no benefit?

    Does anyone know if this guy is for real or a troll? He posts things like this on nearly every post thread.

    You must be new here.

    Nagesh is the generic "Indian" coder made up by a bunch of white people and faked by various other users to amplify negative stereotypes about indian programmers. So no, he is not for real, and there is a minimum of 2^64 "nagesh" posts per wtf thread on this site. You get used to it and sometimes laugh, but never ever reply to it (directly).

  • (cs) in reply to PiisAWheeL
    PiisAWheeL:
    Anon:
    PiisAWheeL:
    Anon:
    We don't all have fancy wide- screen monitors you insensitive clod!
    Does your 3 inch monitor have a scroll bar?

    Hey! Your mom didn't have any problems monitoring my 3 inches with her scroll bar.

    Wow dude... you have just taken offense to everything i've said, and you are taking all of it way too seriously. Do they not have medical marijuana where you live yet? If I was a doctor I would prescribe you some for stress. It looks like you really need it.

    DONT!

    ACCUSE!!

    ME!!!

    OF!!!!

    BEING!!!!!

    !!!!! STRESSED !!!!!

  • Anon (unregistered) in reply to PiisAWheeL
    PiisAWheeL:
    Anon:
    PiisAWheeL:
    Anon:
    We don't all have fancy wide- screen monitors you insensitive clod!
    Does your 3 inch monitor have a scroll bar?

    Hey! Your mom didn't have any problems monitoring my 3 inches with her scroll bar.

    Wow dude... you have just taken offense to everything i've said, and you are taking all of it way too seriously. Do they not have medical marijuana where you live yet? If I was a doctor I would prescribe you some for stress. It looks like you really need it.

    Don't know man. You seem to be the one who doesn't know an obvious joke when he sees it. Maybe you're the one who's stressed?

  • (cs) in reply to PiisAWheeL
    Jeff just stared at the function for a good 10 minutes, trying to figure it out. When he did, it hit him like a ton of bricks. Rather than using the built-in C# date functions, the developer had opted to convert a date into its Unix Epoch -- the number of seconds elapsed since Jan. 1, 1970 -- and work from there.

    Jeff must be kinda slow. You can guess this from the previous line

    int strElapsedDays = ( 
     convertDate(intDay1, intMonth1, intYr1) - 
     convertDate(intDay2, intMonth2, intYr2)) / DAY;
    

    So it's substracting two "converted" dates, and dividing by a constant DAY to get days. Conclusion: convertDate converts to some absolute time format. This is probably the best approach if you have to write your own time-handling library, and it makes sense to reuse Unix time as a standard(instead of, say, half-minutes since 2002).

    Of course it's still very bad coding: never write your own time functions (or input sanitizing functions, or XML parser, or GUI toolkit, or...). You won't get them right. Spend five minutes checking if your language has them instead.

    90% of the WTF code in this site is noobs not knowing that the language has functions for that. Maybe C has made people too used to writing boring parts again and again.

  • Nick V. (unregistered) in reply to Erlando
    Erlando:
    It doesn't account for leap years correctly...

    Exactly. If it was just reinventing the wheel, it would raise the issue of either the programmers being unaware of the builtin functions in C# (or even how to find them on the fly) or them overcharging the company.

    But on top of that it is inaccurate.

    What about pre-1970 dates? Pre-1852 (Gregorian Reform)?

  • Nagesh (unregistered) in reply to PiisAWheeL
    PiisAWheeL:
    Jazz:
    Nagesh:
    This aproach is prefered. Simpler to be converting to C for linux app (much quiker performing) or any system without suport library function. Time function is wel-defined already: why convert to langage-specific fuctions for no benefit?

    Does anyone know if this guy is for real or a troll? He posts things like this on nearly every post thread.

    You must be new here.

    Nagesh is the generic "Indian" coder made up by a bunch of white people and faked by various other users to amplify negative stereotypes about indian programmers. So no, he is not for real, and there is a minimum of 2^64 "nagesh" posts per wtf thread on this site. You get used to it and sometimes laugh, but never ever reply to it (directly).

    This kind of feke accusations are being offensive. I am always having believed that registered Nagesh is real indian from south Hyderabad.

  • John Hensley (unregistered)

    have fun with your libraries, you five-figure salaried peons, we'll be out building a new world

  • n_slash_a (unregistered) in reply to derp
    derp:
    private static int convertDate(int day, int month, int year)
    {
    

    int[] months = new int[] { 0,31,59,90,120,151, 181,212,243,273,304,334 };

    return ( ((year - 1970) * DAY * 365) + (((year - 1970)/4) * DAY) + (months[month - 1] * DAY) + ((day-1) * DAY) ); }

    TRWTF is the ridiculous formatting. Why Must every thing get its own line

    Part of our coding standard is that no line can be over 80 characters. This allows 1) the code to be printed out and 2) the ability to have other windows or tool-bars open next to the code.

  • emaN ruoY ekaf (unregistered) in reply to Nickster
    Nickster:
    emaN ruoY:
    This comment was designed to be Frist.

    Your comment does not function as it was designed. I will submit a bug report.

    WONTFIX

  • s73v3r (unregistered) in reply to Z

    How long do you think it would have taken you to write the program from scratch and get it into working shape?

  • s73v3r (unregistered) in reply to Nagesh
    Nagesh:
    Z:
    TRWTF is expecting outsourced code to work correctly in the first place. Face it, you are working with a bunch of Indian code monkeys who are 'coding to the spec', and who will freely mash whatever unholy code style and practice they are familiar with into your shiny new project, because that is what they know.

    At my company, we are still maintaining an outsourced program I like to refer to as the 'Indian abomination'. After we got the final code drop, it took me another 9 months to get it into working shape, and we still find hidden gems that make us go 'huh?' every once in a while.

    Like any programer, Indian is not mind-reader. All we can code 4 is what customer ask for.

    We're not mind readers either. But you know what we do? We ask.

  • (cs) in reply to ParkinT
    ParkinT:
    "If it ain't broke, don't fix it" So much for Code Excellence!

    If it's not broken you can't fix it. You could make it prettier. Or you could make it faster. Or you could make it easier to maintain. But you couldn't fix it.

  • Nagesh (unregistered) in reply to s73v3r
    s73v3r:
    Nagesh:
    Z:
    TRWTF is expecting outsourced code to work correctly in the first place. Face it, you are working with a bunch of Indian code monkeys who are 'coding to the spec', and who will freely mash whatever unholy code style and practice they are familiar with into your shiny new project, because that is what they know.

    At my company, we are still maintaining an outsourced program I like to refer to as the 'Indian abomination'. After we got the final code drop, it took me another 9 months to get it into working shape, and we still find hidden gems that make us go 'huh?' every once in a while.

    Like any programer, Indian is not mind-reader. All we can code 4 is what customer ask for.

    We're not mind readers either. But you know what we do? We ask.

    Spec is given and folowed. Ain't is there to ask?

  • (cs) in reply to Anon
    Anon:
    PiisAWheeL:
    Anon:
    PiisAWheeL:
    Anon:
    We don't all have fancy wide- screen monitors you insensitive clod!
    Does your 3 inch monitor have a scroll bar?

    Hey! Your mom didn't have any problems monitoring my 3 inches with her scroll bar.

    Wow dude... you have just taken offense to everything i've said, and you are taking all of it way too seriously. Do they not have medical marijuana where you live yet? If I was a doctor I would prescribe you some for stress. It looks like you really need it.

    Don't know man. You seem to be the one who doesn't know an obvious joke when he sees it. Maybe you're the one who's stressed?

    Maybe you're right. I always considered the your mama style retort an "end all because i'm frustrated and don't have a good comeback" kinda response.

    Maybe I'll go and [censored for drug references] and that will solve my stress problems ^_i^

  • Sannois (unregistered) in reply to n_slash_a
    n_slash_a:
    Part of our coding standard is that no line can be over 80 characters. This allows 1) the code to be printed out

    Help! Help! I've fallen through a wormhole and ended up in 1996!

  • (cs) in reply to Nick V.
    Nick V.:
    Erlando:
    It doesn't account for leap years correctly...

    What about pre-1970 dates? Pre-1852 (Gregorian Reform)?

    Good luck collecting on your 1851 invoice when you send it out. This is for a billing system after all.

Leave a comment on “Epoch Billing System”

Log In or post as a guest

Replying to comment #:

« Return to Article