Comment On The 0th Month

Kevin S. works on websites for a living. [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: The 0th Month

2010-07-26 09:03 • by frits
Mmm. Sweet, sweet apples.

Re: The 0th Month

2010-07-26 09:04 • by Michael (unregistered)
why oh why?? at least after the third "if" the dev should have figured out that there is somehow a pattern....

Re: The 0th Month

2010-07-26 09:06 • by snoofle
Grind it up and make apple sauce

Re: The 0th Month

2010-07-26 09:08 • by Scott (unregistered)
Indenting code like that is for streamlining - it makes it faster.

Re: The 0th Month

2010-07-26 09:08 • by GrailSeekr (unregistered)
This post is pre-dated Apples 0th, 2038. Epoch fail.

Re: The 0th Month

2010-07-26 09:08 • by EatenByAGrue (unregistered)
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)

Re: The 0th Month

2010-07-26 09:11 • by Candy (unregistered)
Oh monther...

Re: The 0th Month

2010-07-26 09:12 • by The Nerve (unregistered)
Several things the developer needs to "learn."

1. No such thing as const reference in PHP.
2. Hard-coded values are generally bad.
3. Whitespace is optional: ergo it's there to make the code more readable, not less.

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.

Re: The 0th Month

2010-07-26 09:16 • by Seriously curious (unregistered)
I will soon be looking for a job as a programmer. Do you really need no skills to get one?

Re: The 0th Month

2010-07-26 09:17 • by Mr. S (unregistered)
315441 in reply to 315439
The Nerve:
Several things the developer needs to "learn."

1. No such thing as const reference in PHP.
2. Hard-coded values are generally bad.
3. Whitespace is optional: ergo it's there to make the code more readable, not less.

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.


What about FILE_NOT_FOUND?

Re: The 0th Month

2010-07-26 09:20 • by Anonymous (unregistered)
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.

Re: The 0th Month

2010-07-26 09:21 • by Robyrt (unregistered)
And why is there a period after May?

Re: The 0th Month

2010-07-26 09:22 • by The Nerve (unregistered)
Oh, wait. I think I figured out how the indentation got that way. Here's the previous iteration.

<? //convert month number to month name
function monther($inter){
$months = array("Apples", "Jan.", "Feb.", "Mar.", "Apr.", "May.", "Jun.", "Jul.",
"Aug.", "Sept.", "Oct.", "Nov.", "Dec.");
if($inter == 1){
echo $months[1];
} else {
if($inter == 2){
echo $months[2];
} else {
if($inter == 3) {
echo $months[3];
} else {
if($inter == 4) {
echo $months[4];
} else {
if($inter == 5) {
echo $months[5];
} else {
if($inter == 6) {
echo $months[6];
} else {
if($inter == 7) {
echo $months[7];
} else {
if($inter == 8) {
echo $months[8];
} else {
if($inter == 9) {
echo $months[9];
} else {
if($inter == 10) {
echo $months[10];
} else {
if($inter == 11) {
echo $months[11];
} else {
if($inter == 12) {
echo $months[12];
}
}
// end converting month
?>


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.

Re: The 0th Month

2010-07-26 09:24 • by Anonymous (unregistered)
315445 in reply to 315440
Seriously curious:
I will soon be looking for a job as a programmer. Do you really need no skills to get one?

It's possible, the only problem is that you'll end up working for the sort of company that gets posted about on TDWTF. Trust me, that's not something you want. Far better to get a decent job with an employer that appreciates a genuine skillset.

Re: The 0th Month

2010-07-26 09:24 • by robo (unregistered)
Truly inspirational

Re: The 0th Month

2010-07-26 09:25 • by Sam (unregistered)
If the 0th month was "Smarch" I might have died.

Re: The 0th Month

2010-07-26 09:27 • by Pokepoke (unregistered)
If the earth dies and the 0 month occurs, this guy is prepared!

Re: The 0th Month

2010-07-26 09:32 • by notadummy (unregistered)
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.

Re: The 0th Month

2010-07-26 09:33 • by bl@h (unregistered)
function monther($inter), did anyone ready this as 'mother' ? I was expecting a return of $offspring





Re: The 0th Month

2010-07-26 09:34 • by Rajendra Kumar (unregistered)
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.

Re: The 0th Month

2010-07-26 09:35 • by Aaron
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...

Re: The 0th Month

2010-07-26 09:36 • by MP (real) (unregistered)
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.

Re: The 0th Month

2010-07-26 09:37 • by MP (real) (unregistered)
315454 in reply to 315451
Rajendra Kumar:
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.


TRWTF

Re: The 0th Month

2010-07-26 09:38 • by wtf (unregistered)
315455 in reply to 315452
Apples is the cruelest month. Except for Frimaire.

Re: The 0th Month

2010-07-26 09:39 • by frits
315456 in reply to 315452
Aaron:
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...


Right...Because an array is the right answer.

Re: The 0th Month

2010-07-26 09:42 • by prionic6 (unregistered)
315457 in reply to 315451
Rajendra Kumar:
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.


Great comment! Enjoyed it. Would read again.

Re: The 0th Month

2010-07-26 09:43 • by VictorSierraGolf (unregistered)
AAAAAaaaaaaaarhg! My head hurts...

Re: The 0th Month

2010-07-26 09:45 • by frits
315460 in reply to 315457
Thanks! ;)

Re: The 0th Month

2010-07-26 09:45 • by the beholder (unregistered)
315461 in reply to 315443
Robyrt:
And why is there a period after May?
Because it's an abbreviation of the month named Mayonnaise. Which is fortunately four months apart from Apples, because apples and mayonnaise don't go well together

Re: The 0th Month

2010-07-26 09:50 • by frits
315463 in reply to 315461
the beholder:
Robyrt:
And why is there a period after May?
Because it's an abbreviation of the month named Mayonnaise. Which is fortunately four months apart from Apples, because apples and mayonnaise don't go well together


Apparently you've never heard of Waldorf salad.

Re: The 0th Month

2010-07-26 09:52 • by ObiWayneKenobi
315464 in reply to 315440
Seriously curious:
I will soon be looking for a job as a programmer. Do you really need no skills to get one?


You need the most important skill of all: The ability to hoodwink whoever is interviewing you that you know everything.

Re: The 0th Month

2010-07-26 09:53 • by Buddy (unregistered)
I like the period after May, and how September is abbreviated to four characters while the other months are abbreviated three characters.

Re: The 0th Month

2010-07-26 09:55 • by toth
Ah, a classic WTF. Bad indenting, hilarious! What a shame it ruins otherwise great code!

Re: The 0th Month

2010-07-26 09:56 • by ubersoldat
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!

Re: The 0th Month

2010-07-26 09:57 • by gizmore (unregistered)
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();
}

Re: The 0th Month

2010-07-26 09:57 • by Burpy (unregistered)
As long as a code has the slightest thing to do with Apple then it's definitely a WTF!

Re: The 0th Month

2010-07-26 10:00 • by nobulate
function monther($inter) does not return any value. It does, however, echo the answer. WTF!

Re: The 0th Month

2010-07-26 10:03 • by SCSimmons
315472 in reply to 315439
The Nerve:

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.

'Bulletproof' is only a good attribute for code that you don't want to kill with a hail of gunfire.

Re: The 0th Month

2010-07-26 10:08 • by Bryan The K (unregistered)
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.

Re: The 0th Month

2010-07-26 10:08 • by nobulate
315475 in reply to 315465
It shows a period after every month on my tty. Do I need Web 2.0 uniascii codepage support perhaps?

Re: The 0th Month

2010-07-26 10:09 • by Darth Tabeous (unregistered)
I have indented the code...pray I don't indent it any further.

Re: The 0th Month

2010-07-26 10:15 • by John (unregistered)
315477 in reply to 315439
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.

Re: The 0th Month

2010-07-26 10:19 • by kjordan (unregistered)
No oranges month?

Re: The 0th Month

2010-07-26 10:19 • by Ronan (unregistered)
Not really a WTF, that's the standard way of coding with Joomla (according.

Re: The 0th Month

2010-07-26 10:20 • by Jonathan
That is a monther-functer.

Re: The 0th Month

2010-07-26 10:21 • by Ronan (unregistered)
...according to the code of most extensions available on the official joomla repository).

Re: The 0th Month

2010-07-26 10:22 • by Bernie (unregistered)
315482 in reply to 315443
Robyrt:
And why is there a period after May?

Testing. Notice that all the valid months end with a period while Apples does not.

Re: The 0th Month

2010-07-26 10:27 • by Peter (unregistered)
Eat an apple, and go with the flow man!

The Secret Source

2010-07-26 10:27 • by nobulate
This code is designed for something.. bigger. Any noob can just call:
return months[$inter];

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.

Re: The 0th Month

2010-07-26 10:32 • by Pedro (unregistered)
315485 in reply to 315447
Smarch is the 13th month, not the 0th.

Damn Smarch weather!


Captha: acsi - Dyslexic character code
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment