- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
A new method: The "For-Get" method.;;
Admin
A failed attempt at internationalization (i18n), where you could store descriptors for different languages in the second array.
Admin
Yes, let for-get this method as soon as possible
Admin
What? No MonthNumberDigtizationFactoryGeneratorInterface?
Admin
You'll probably want to import something from the alcohol package to make proper use of for-get.
Admin
So january is the 0th month of the year now?
Admin
@Vilx: No, it's not properly enterprise-ey, is it? A missed opportunity.
Admin
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.Admin
I'm missing the regex ...
Admin
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!
Admin
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".
Admin
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:
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...
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.
Admin
Includes bonus race-condition!
Admin
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.
Admin
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).
Admin
That really feels like an excuse. The whole idea of storing this in an array of string arrays requires a serious failure of thinking.
Admin
Anyone see this but in SQL complete with a MONTHS table in the app schema? Goes from WTF to WTAF in seconds.
Admin
"[...] 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.