• profke (unregistered)

    A new method: The "For-Get" method.;;

  • LazerFX (unregistered)

    A failed attempt at internationalization (i18n), where you could store descriptors for different languages in the second array.

  • DQ (unregistered) in reply to profke

    Yes, let for-get this method as soon as possible

  • Vilx- (unregistered)

    What? No MonthNumberDigtizationFactoryGeneratorInterface?

  • Canthros (unregistered) in reply to profke

    You'll probably want to import something from the alcohol package to make proper use of for-get.

  • Ann Onymous (unregistered)

    So january is the 0th month of the year now?

  • RLB (unregistered) in reply to Vilx-

    @Vilx: No, it's not properly enterprise-ey, is it? A missed opportunity.

  • WTFGuy (unregistered)

    FactoryGenerator?? We don' need no steekin' FactoryGenerator. We/They can foul this up 1990s style even better than 2020's style.

    Maybe the array should be wider, say with another column for the short form of the month ("Jan","Feb", etc.), and one for the month length in each of regular & leap years, first day of month offset in year, etc. Stored as quoted strings of digits of course. With an additional opaque int parameter to select which column to return. And doubtless there's a typo or two embedded in the initializing code. Which even when discovered can't be fixed due to fears of introducing downstream errors.

    Then add another dimension to the array to represent various languages. Using of course the now-deprecated Windows LCID as that index. So e.g. the US English plane of the array would be indexed at [1033]. With of course a separate class to map those LCIDs to some home-brew naming convention that almost but not quite matches the ISO naming conventions (e.g. "en-US"). Bonus points for adding this feature as an afterthought so it ends up being the rightmost = fastest varying index ensuring each month of any given LCID will end up in different RAM pages thereby maximizing the working set.

  • Hasseman (unregistered)

    I'm missing the regex ...

  • {"13", "Smarch"} (unregistered)

    Someone not only didn't know about built in date formatting, but also maps.

    It's not really a WTF so much as obviously the product of a new or uneducated programmer. Maybe that person is now more experienced and is reading today's WTF and laughing at how dumb he was back in the day!

  • (nodebb) in reply to {"13", "Smarch"}

    It's not really a WTF so much as obviously the product of a new or uneducated programmer.

    This is like an air conditioner repair guy not knowing how to use a manifold gauge set. I'm always surprised at how many people get a really good paycheck and are soooo bad at their jobs. I'm also surprised at how many people think it's OK and "just part of the learning curve".

  • Rob (unregistered)

    A Map<Integer, String> would have been better than this. For instance, there would be no need to parse the "keys" every time. Given that months should have values from 0 (...) to 11 the auto-boxing wouldn't even create new Integer objects.

    Of course there are, besides SimpleDateFormat, better ways to do this:

    1. Use DateFormatSymbols. It's like using SimpleDateFormat but, in this case, easier. It has a getMonths() method that returns a String[] with the month names. You index it with Calendar.JANUARY to Calendar.DECEMBER (or even Calendar.UNDECIMBER...). Those are also 0-based though...

    2. Forget the java.util date/time classes and use java.time.Month. It has a nice of method that converts an int (finally 1-based) into a Month constants. That's when it gets a bit harder, because you have to use getDisplayName with both a TextStyle and a Locale.

  • Daryl (unregistered)

    Includes bonus race-condition!

  • Robert (unregistered)

    TRWTF is Java month numbering. At least it is for anyone who writes the month with figures rather than letters. At least JodaTime provides a workaround.

  • MiserableOldGit (unregistered)

    Maybe he comes from some language where array order is not guaranteed, or got burned once iterating through a set and now massively over-compensates.

    Or he was going to add other stuff into the 2nd dimension and just decided not to.

    Yeah, it's dumb and inefficient, but pretty tame, especially by the standards of date WTFery, most especially Jave (pre version 8 January really was the 0th month).

  • (nodebb) in reply to MiserableOldGit

    That really feels like an excuse. The whole idea of storing this in an array of string arrays requires a serious failure of thinking.

  • David W. (unregistered)

    Anyone see this but in SQL complete with a MONTHS table in the app schema? Goes from WTF to WTAF in seconds.

  • aPotato (unregistered)

    "[...] SimpleDateFormat, but the documentation can often be hard to read." -> https://docs.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html -> 404 Page not Found

    well, yes, the documentation can be hard to read.

Leave a comment on “Classic WTF: Dimensioning the Dimension”

Log In or post as a guest

Replying to comment #:

« Return to Article