- 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
Mmm. Sweet, sweet apples.
Admin
why oh why?? at least after the third "if" the dev should have figured out that there is somehow a pattern....
Admin
Grind it up and make apple sauce
Admin
Indenting code like that is for streamlining - it makes it faster.
Admin
This post is pre-dated Apples 0th, 2038. Epoch fail.
Admin
Apparently Kevin S's predecessors have the same power to create months out of thin air as Julius and Augustus Caesar.
captcha: suscipere (to acknowledge a Roman-related wtf)
Admin
Oh monther...
Admin
Several things the developer needs to "learn."
To his credit, at least this code is bulletproof. It will never print "Apples," nor will it crash if 13, -82, 3.14, or "Hallelujah" is passed.
Captcha: amet -- amet fan is frequently disappointed.
Admin
I will soon be looking for a job as a programmer. Do you really need no skills to get one?
Admin
What about FILE_NOT_FOUND?
Admin
I always feel a bit wrecked when I wake up on New Year's Day but I never realised that I was sleeping through the entire month of Apples.
Admin
And why is there a period after May?
Admin
Oh, wait. I think I figured out how the indentation got that way. Here's the previous iteration.
Now to make sure it never prints "Apples" and to avoid an arithmetic operation and to make sure you don't have to do a type-check and never have an out-of-bounds error, this would be quicker (assuming equal penalties of extra checks) for valid values Jan.-Mar. Ergo, perhaps we can rule out insanity and settle for a verdict of felony ignorance and misdemeanor pre-mature optimization.
Admin
Admin
Truly inspirational
Admin
If the 0th month was "Smarch" I might have died.
Admin
If the earth dies and the 0 month occurs, this guy is prepared!
Admin
I consider myself not a programmer. I hack around with PHP now and again to get things done and it sometimes works. I learned how to "program" things by looking at someone else's (who I was told later wasn't a very good programmer) ColdFusion work and copying it.
I would not ever take a job as a programmer because I simply am not qualified. Nowhere near.
And yet, even I wouldn't produce code like that. I would be a step up from whoever wrote that code. Outstanding.
Admin
function monther($inter), did anyone ready this as 'mother' ? I was expecting a return of $offspring
Admin
Dear colleague, I have requirements for this exact code. Except I needing the months in Arabic or Hindi. Could you pls post the code? Also, I have doubts about JUnit testing for this. Could you pls provide this as well? It's urgent! pls! Tnanks in advance.
Admin
No doubt the original code was just a bunch of if/else/return statements; somebody caught wind of this and told the code monkey, "you idiot, use an array!" And he did...
Admin
I'm not sure, but I may be Kevin S., because even though I didn't submit this story, I'm pretty sure I work on this "codebase".
captcha: jugis - When the previous developer returned for a visit, I went straight for the jugis.
Admin
TRWTF
Admin
Apples is the cruelest month. Except for Frimaire.
Admin
Right...Because an array is the right answer.
Admin
Great comment! Enjoyed it. Would read again.
Admin
AAAAAaaaaaaaarhg! My head hurts...
Admin
Thanks! ;)
Admin
Admin
Apparently you've never heard of Waldorf salad.
Admin
You need the most important skill of all: The ability to hoodwink whoever is interviewing you that you know everything.
Admin
I like the period after May, and how September is abbreviated to four characters while the other months are abbreviated three characters.
Admin
Ah, a classic WTF. Bad indenting, hilarious! What a shame it ruins otherwise great code!
Admin
You know, I've always have bad words for VBA programmers, but lately PHP people are getting in my nerves... I have a PHP guy on my side who codes with Dreamweaver and I'm pretty sure he'll pull something like this... Hell!
Admin
It`s also nice to read the src-comment "convert month number to month name" and then using echo to output it.
Good luck here is a wrapper function in case you need to use the value instead of just outputting it:
function getMonther($inter) { ob_start(); monther($inter); return ob_get_clean(); }
Admin
As long as a code has the slightest thing to do with Apple then it's definitely a WTF!
Admin
function monther($inter) does not return any value. It does, however, echo the answer. WTF!
Admin
Admin
The real wtf is that he was supposed to use, string date ( string $format [, int $timestamp ] right??
Either that or he was supposed to be using XML somehow. Maybe to have a MySQL database that returns the month of the year when you pass in the numerical value. This comes back as an XML Response that he can de-serialize and echo out.
If you'll excuse me I have a wooden table, a camera and a print-out that I need to address.
Admin
It shows a period after every month on my tty. Do I need Web 2.0 uniascii codepage support perhaps?
Admin
I have indented the code...pray I don't indent it any further.
Admin
The real WTF is that since all arrays in PHP are hashes and digits are transparently converted; the entirety of the code could be done with no bump element, an integer=>string array, and an isset test with a throw when there's no conversion.
Oi! What a mess. See the trees not the forest.
Admin
No oranges month?
Admin
Not really a WTF, that's the standard way of coding with Joomla (according.
Admin
That is a monther-functer.
Admin
...according to the code of most extensions available on the official joomla repository).
Admin
Admin
Eat an apple, and go with the flow man!
Admin
This code is designed for something.. bigger. Any noob can just call:
No this was designed like this, it has a purpose. I think I found that purpose: copy/paste the code and zoom out, it makes a pattern... Now if we can just find out what it all means. [image]Admin
Smarch is the 13th month, not the 0th.
Damn Smarch weather!
Captha: acsi - Dyslexic character code