- 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
Geniuses are always misunderstood the frist time.
Admin
To be fair, technically PHP doesn't have arrays - an array is just a dictionary/map with a numeric key. But the whole construct still looks weird, especially without any additional context...
Admin
Sadly, a daily total would end up as a W Th F, thanks to that pesky Tuesday coming first.
Admin
$comments = array("frist" => "Moderation", "secnod" => "Comment", "thrid" => "Moderation")
Admin
Why not use Ja, Fe, Mr, Ap, My, Ju, Jl, Au, Se, Oc, No, and De for the keys?
Admin
I disagree with the article. I did not write this code but I still love it. I especially love the attention to detail that it took to make sure he only used a second character where absolutely necessary. It would have been so easy to spell it all in two letters or worse yet whole words wasting space unforgivably.
This said, I would have used fv for five and tr for three. Those letter combinations phonetically sound more like the numbers they represent in my view. But that's just personal preference.
Admin
<irony>The commodity market is in good hands</irony>
Admin
I semi-agree w LZ79LRU. It's bad is a good way which is better than our usual badness in a bad way.
Had the names been inconsistent, or one of them misspelled or them out of order in the constructor, that would have been the usual haphazard chaos-of-mind we're used to critiquing. No chaos here; just weirdness.
The only legit motivation / saving grace I can imagine for this idea is to distinguish between "months" as in absolute calendar months (1=Jan, 2=Feb, ...) versus relative months. Today being in Dec as I write, that's "o" = Nov, "t"= Oct, etc. It's essentially the same motivation as Systems Hungarian, decorating the key with a semantic meaning.
To be sure, a properly named enum for key values
{OneMonthAgo, TwoMonthsAgo, ...}
or an object with propertiesOneMonthAgo, TwoMonthsAgo
etc would be a better tool to do the same thing. And with some accessor / converter methods to take an index month and offset month asDateTime
objects or asint
s and deliver up the right results.But if we had that, we'd have no WTF.
Admin
It's job security. And if they do let you go anyway, then you have a bit of instant karma.
Admin
Sure, but instant karma may be negative...
Admin
Actually this solution makes perfect sense when you consider that... um... no wait..., ok I give up
Admin
Job security by obscurity
Admin
OK. You got me. This is the first one where my jaw quite literally dropped.
This is f@&#ing INSANE.
Admin
('o' => 23141, 't' => 23142, 'th' => 42432, 'f' => 63243, 'fi' => 21422);
"o"ne "t"wo "th"ree "f"our "fi"ve
Makes perfect since in a twisted sort of sense.
Admin
reminds me of an older story where someone wrote a program to verify the Months, BUT he ran all them all together, "janfebmar"etc, so "anf" and "nfe" would pass!
Admin
So there are 5 magic numbers in this code, that when 'next month' runs around, have all to be edited. fi drops off, f becomes fi, th becomes f, t becomes th, o becomes t, and the new month gets added as o. Or is it the other way around, and o drops off, all the others shift and new one gets added as f??
It is at least easily extendable, if we later need another 7 months of history to make a full year we just add s, se, e, n, te, el and tw to the array (and add to the steps we follow as above when a new month starts). Gets harder if we need 13 months though. th is already used, but I see no reason why we have to stay in English, there are MANY languages in the world and surely one of them must have the word for 13 start with letters we haven't used!