New Job; New Codebase; New WTFs



  • Constants.java:

    public final static int DAYS_IN_MONTH = 30;

    public final static int DAYS_IN_3_MONTHS = 3 * 31;  // OP: yes, that's thirty-ONE!

    public final static int DAYS_IN_YEAR = 12 * DAYS_IN_MONTH + 5;  // Not sure what to do for leap years (OP: their comment, not mine)

     



  • public final static int WTFS = (int) Long.MAX_VALUE;





  • @snoofle said:

    Constants.java:

    public final static int DAYS_IN_MONTH = 30;

    public final static int DAYS_IN_3_MONTHS = 3 * 31;  // OP: yes, that's thirty-ONE!

    public final static int DAYS_IN_YEAR = 12 * DAYS_IN_MONTH + 5;  // Not sure what to do for leap years (OP: their comment, not mine)

     

    So they've found a way to put 377 days into a year?  Cool!  Now if they can put more hours into the day, they could market that and make a mint!



  • @snoofle said:

    // Not sure what to do for leap years

    I really, really like this comment. Goes to show how well they thought everything through before starting to code.



  • Why on god green earth this crap still happens, I mean, there are a gazillion libraries that handle time and date for you, why one would feel compelled to go and fuck it?


  • Trolleybus Mechanic

    @serguey123 said:

    why one would feel compelled to go and fuck it?
     

    Because there weren't any alligators available?



  • @Lorne Kates said:

    @serguey123 said:

    why one would feel compelled to go and fuck it?
     

    Because there weren't any alligators available?

    You haven't enjoyed life until you try that

    However I'm pretty sure that wherever the chap responsable for this code lives there are surrogates that although not as good can provide some entertainment



  • @snoofle said:

    Constants.java:

    public final static int DAYS_IN_MONTH = 30;

    public final static int DAYS_IN_3_MONTHS = 3 * 31;  // OP: yes, that's thirty-ONE!

    public final static int DAYS_IN_YEAR = 12 * DAYS_IN_MONTH + 5;  // Not sure what to do for leap years (OP: their comment, not mine)

     

    Presumably you're in a position to be able to fix it?


  • ♿ (Parody)

    @Matt Westwood said:

    Presumably you're in a position to be able to fix it?

    WTFs like this can't be fixed! Think of all of the code that relies on the garbage calculations.



  • @boomzilla said:

    @Matt Westwood said:
    Presumably you're in a position to be able to fix it?

    WTFs like this can't be fixed! Think of all of the code that relies on the garbage calculations.

    I was thinking the same thing. You "fix" this, and you'll get angry phone calls demanding to know why the numbers for this quarter are so different from last quarter... well last quarter had 93 days in it.

    This problem occurred before the code got written; it occurred when the type of "programmer" who thinks this code is acceptable was hired and given responsibility to design a system in the first place. If he hadn't made this specific error, he would have made another one equally fundamental.



  • @blakeyrat said:

    This problem occurred before the code got written; it occurred when the type of "programmer" who thinks this code is acceptable was hired and given responsibility to design a system in the first place. If he hadn't made this specific error, he would have made another one equally fundamental.
     

    This code does look worrisome but it could be more of a misnamed constants thing (we can hope at least); maybe a contract says "retain records for 93 days" which got the constant named DAYS_IN_3_MONTHS instead of something intelligible like RETENTION_DAYS.

    Not that I think this interpretation is correct, but it's possible and I prefer to think of people as malicious than incompetent.



  • @locallunatic said:

    @blakeyrat said:

    This problem occurred before the code got written; it occurred when the type of "programmer" who thinks this code is acceptable was hired and given responsibility to design a system in the first place. If he hadn't made this specific error, he would have made another one equally fundamental.
     

    This code does look worrisome but it could be more of a misnamed constants thing (we can hope at least); maybe a contract says "retain records for 93 days" which got the constant named DAYS_IN_3_MONTHS instead of something intelligible like RETENTION_DAYS.

    Not that I think this interpretation is correct, but it's possible and I prefer to think of people as slighly incompetent than totally incompetent.

    FTFY

    Giving retarded names to variables doesn't make him/her competent.



  • @serguey123 said:

    @locallunatic said:

    @blakeyrat said:

    This problem occurred before the code got written; it occurred when the type of "programmer" who thinks this code is acceptable was hired and given responsibility to design a system in the first place. If he hadn't made this specific error, he would have made another one equally fundamental.
     

    This code does look worrisome but it could be more of a misnamed constants thing (we can hope at least); maybe a contract says "retain records for 93 days" which got the constant named DAYS_IN_3_MONTHS instead of something intelligible like RETENTION_DAYS.

    Not that I think this interpretation is correct, but it's possible and I prefer to think of people as slighly incompetent than totally incompetent.

    FTFY

    Giving retarded names to variables doesn't make him/her competent.

     

    Bad naming can be done on purpose in order to cause confusion, so malicious totally applies here.



  • @locallunatic said:

    @serguey123 said:

    @locallunatic said:

    @blakeyrat said:

    This problem occurred before the code got written; it occurred when the type of "programmer" who thinks this code is acceptable was hired and given responsibility to design a system in the first place. If he hadn't made this specific error, he would have made another one equally fundamental.
     

    This code does look worrisome but it could be more of a misnamed constants thing (we can hope at least); maybe a contract says "retain records for 93 days" which got the constant named DAYS_IN_3_MONTHS instead of something intelligible like RETENTION_DAYS.

    Not that I think this interpretation is correct, but it's possible and I prefer to think of people as slighly incompetent than totally incompetent.

    FTFY

    Giving retarded names to variables doesn't make him/her competent.

     

    Bad naming can be done on purpose in order to cause confusion, so malicious totally applies here.

    But if I considered obfuscation as a reason to do so I wouldn't be able to make a post to correct your post.  My world view might collapse.



  • @locallunatic said:

    @blakeyrat said:

    This problem occurred before the code got written; it occurred when the type of "programmer" who thinks this code is acceptable was hired and given responsibility to design a system in the first place. If he hadn't made this specific error, he would have made another one equally fundamental.
     

    This code does look worrisome but it could be more of a misnamed constants thing (we can hope at least); maybe a contract says "retain records for 93 days" which got the constant named DAYS_IN_3_MONTHS instead of something intelligible like RETENTION_DAYS.

    Not that I think this interpretation is correct, but it's possible and I prefer to think of people as malicious than incompetent.

    Nope: it's correctly named - they wanted the number of days in 3 months, but which 3 months makes a difference. This happens to be used only for the third quarter, so Jul, Aug and Sep - rounds up to 31 (per the dev who wrote it: "it's close enough").

    This is just the tip of the iceberg. Today we found a homemade xml parser that treats all whitespace around tags as significant.



  • @snoofle said:

    This is just the tip of the iceberg. Today [b]we[/b] found a homemade xml parser that treats all whitespace around tags as significant.

    That line implies that you are not the only new guy looking at this code. Of course a homemade xml parser is a wtf in a language like java.



  • @serguey123 said:

    ... there are a gazillion libraries that handle time and date for you ...

    Considering that this is Java, you don't even need a library, the 'Calendar' family of objects is build right in (GregorianCalendar etc.). Okay, Calendar might not be pretty and a pain to use and somewhat limited in what it is capable of, but (as far as my experience goes) at least it does seem to get those things right.

    @Mason Wheeler said:

    @snoofle said:
    Constants.java:

    public final static int DAYS_IN_MONTH = 30;

    public final static int DAYS_IN_3_MONTHS = 3 * 31;  // OP: yes, that's thirty-ONE!

    public final static int DAYS_IN_YEAR = 12 * DAYS_IN_MONTH + 5;  // Not sure what to do for leap years (OP: their comment, not mine)

    So they've found a way to put 377 days into a year?  Cool!  Now if they can put more hours into the day, they could market that and make a mint!
    Now, I love a good WTF as much as the next guy, but you don't have to fabricate them from what isn't really there. 12 * 30 (= DAYS_IN_MONTH) + 5 is still 365, so that's (mostly) correct (in a twisted kind of way).

    Even if you went with 4 * DAYS_IN_3_MONTHS, that would still only be 372...



  • @Anonymouse said:

    @serguey123 said:

    ... there are a gazillion libraries that handle time and date for you ...

    Considering that this is Java, you don't even need a library, the 'Calendar' family of objects is build right in (GregorianCalendar etc.). Okay, Calendar might not be pretty and a pain to use and somewhat limited in what it is capable of, but (as far as my experience goes) at least it does seem to get those things right.

    @Mason Wheeler said:

    @snoofle said:
    Constants.java:

    public final static int DAYS_IN_MONTH = 30;

    public final static int DAYS_IN_3_MONTHS = 3 * 31;  // OP: yes, that's thirty-ONE!

    public
    final static int DAYS_IN_YEAR = 12 * DAYS_IN_MONTH + 5;  // Not sure
    what to do for leap years (OP: their comment, not mine)

    So
    they've found a way to put 377 days into a year?  Cool!  Now if they
    can put more hours into the day, they could market that and make a mint!
    Now, I love a good WTF as much as the next guy, but you don't have to fabricate them from what isn't really there. 12 * 30 (= DAYS_IN_MONTH) + 5 is still 365, so that's (mostly) correct (in a twisted kind of way).

    Even if you went with 4 * DAYS_IN_3_MONTHS[b] + 5[/b], that would still only be 37[b]7[/b]...

    FTFY, but yes, you are correct about the constant multiplier.


Log in to reply