Comment On Date Selector of the Damned

"It's no secret that web developers are generally considered the red headed stepchildren of programming, and with good reason," writes Joe. "With its proliferation of forgiving and loosely structured languages and the huge demand for web developers in our modern web-centric world, it's not surprising that the field is practically overrun by script monkeys with no real programming background. Armed with a shelf full of books on all the latest web technologies and a subscription to Experts' Exchange, they enthusiastically pound away at their keyboards day after day, happily and cluelessly producing oceans of spaghetti code so bad that even Olive Garden wouldn't serve it." [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: Date Selector of the Damned

2012-06-18 11:20 • by GettinSadda
The only way that I can currently think of to make that worse is to expect the user to enter the month in Morse code!

Re: Date Selector of the Damned

2012-06-18 11:26 • by snoofle
I know *nothing* of web development, but wouldn't it be reasonable to assume that there is some sort of calendar widget available that one might use instead of writing all that?

Re: Date Selector of the Damned

2012-06-18 11:27 • by Nagesh (unregistered)
I see no problem with this code. It is a work of art!

Re: Date Selector of the Damned

2012-06-18 11:33 • by jonny_q (unregistered)
383335 in reply to 383333
snoofle:
I know *nothing* of web development, but wouldn't it be reasonable to assume that there is some sort of calendar widget available that one might use instead of writing all that?


HTML5 allows for <input type=date> and as browsers gain support for it, it will be that simple to display a date widget.

However, even today, not all browsers support it. Like the article said, there are a number of third-party scripts out there that do the job quite well. A very method is to include the jQuery UI lib on your page:

<label><b>Date</b> <input class=date name=birthdate></label>
...
<script>$(function() {
$('input.date').datepicker();
// wipe hands on pants
});</script>


So, yes.

I dumbed down the code there a bit, and there's probably a more thorough answer, but that's the quick answer to your question.

Re: Date Selector of the Damned

2012-06-18 11:34 • by DWalekr59 (unregistered)
Instead of JUST laughing at the programmer here, someone should replace that code with what ought to be there and then SHOW IT TO the programmer. Ask them what they think of the replacement.

Make a comment to them like "you know, there are some situations where, when you see them, you ought to think "I'm sure this has been solved before -- let's look around for the best and simplest way to implement this".".

Javascript?

2012-06-18 11:35 • by Kasper (unregistered)
There is not much reason to be using javascript in the first place. That page could have worked just as fine without any javascript. The only thing that javascript could really do for such a page is to present an error message to the user slightly faster, if the input is inconsistent (like specifying the 30th of February or such).

You are going to need validation on the server side anyway. As a user I'd much rather see a solution that only validates on the server side than one, that does a poor job of validating on the client side.

Re: Date Selector of the Damned

2012-06-18 11:35 • by barfoo
383338 in reply to 383332
Obviously you lack creativity. The worse version would involve inputting the date in Julian and writing a routine to convert it to Gregorian.

Re: Date Selector of the Damned

2012-06-18 11:36 • by Chronomium (unregistered)
Why is the year box about 40% wider than the other two?

Why is "check" abbreviated in the comments to "ck"?

Why Are the Alerts in Title Case!?

Why is the order month/day/year?

So many subtle things here.

All web developers?

2012-06-18 11:37 • by Patrick Bell (unregistered)
Because web developers are the only programmers who write horribly mangled code, amirite? Please. And yet it is taboo to say that C/C++ have held the state of the art in software back by several decades due to their extreme low-level concepts and lack of portability?

Dear Daily WTF,

I came for the lulz, and left because of the sickening elitism among your submitters and commentors whose lives are now so devoid of meaning that the only pleasure they get is derived from heckling the less gifted.

Enjoy your passive aggressive snickering and your tiny cubicles while you hide from doing real work.

*plonk*

Sincerely,
Patrick

Re: All web developers?

2012-06-18 11:39 • by Anon (unregistered)
383341 in reply to 383340
Patrick Bell:
Because web developers are the only programmers who write horribly mangled code, amirite? Please. And yet it is taboo to say that C/C++ have held the state of the art in software back by several decades due to their extreme low-level concepts and lack of portability?

Dear Daily WTF,

I came for the lulz, and left because of the sickening elitism among your submitters and commentors whose lives are now so devoid of meaning that the only pleasure they get is derived from heckling the less gifted.

Enjoy your passive aggressive snickering and your tiny cubicles while you hide from doing real work.

*plonk*

Sincerely,
Patrick


Looks like the author of today's submission has been unearthed.

First clue

2012-06-18 11:39 • by An on (unregistered)
> // final Date string to be passed to SAP is stored here

^^^^^

That's your first clue as to "why" right there.

Once you've spent some time with SAP, anything else looks good, especially on the UI front...

Re: Javascript?

2012-06-18 11:48 • by Tim (unregistered)
383343 in reply to 383337
Kasper:
There is not much reason to be using javascript in the first place. That page could have worked just as fine without any javascript. The only thing that javascript could really do for such a page is to present an error message to the user slightly faster, if the input is inconsistent (like specifying the 30th of February or such).

You are going to need validation on the server side anyway. As a user I'd much rather see a solution that only validates on the server side than one, that does a poor job of validating on the client side.
Kasper is correct. You must validate all data on the server, because you cannot count on being in control of the client. Once you understand that, client-scripted validation is merely sugar to help the babies who don't know how to enter dates yet.

Re: All web developers?

2012-06-18 11:48 • by mrfr0g (unregistered)
383344 in reply to 383340
Patrick Bell:
Because web developers are the only programmers who write horribly mangled code, amirite? Please. And yet it is taboo to say that C/C++ have held the state of the art in software back by several decades due to their extreme low-level concepts and lack of portability?

Dear Daily WTF,

I came for the lulz, and left because of the sickening elitism among your submitters and commentors whose lives are now so devoid of meaning that the only pleasure they get is derived from heckling the less gifted.

Enjoy your passive aggressive snickering and your tiny cubicles while you hide from doing real work.

*plonk*

Sincerely,
Patrick


Hey congratulations! You just got the point of this website, to make fun of poorly written code. Today it is a javascript WTF, tomorrow it might be c/c++, Java, classic ASP, or really anything else "code" related.

I am a Web Developer, have been for a number of years and I can say with certainty that the code posted today is terrible, and deserves to be made fun of.

CATPCHA: letatio, some kind of levitating potato or Harry Potter spell

Re: Date Selector of the Damned

2012-06-18 11:49 • by ubersoldat
This is why college education is broken. They teach you so many things, except to look at the API. Go to any college class which is doing any development and show them the API to their current language... the looks of awe are simply amazing and the sheep stand there wondering of a whole new world of opportunities.
So please people, stop reinventing new ways of fucking up date implementations. How many articles have appeared here where the subject is implementing his/her new Gregorian calendar?
Oh! And TRWTF is JavaScript for not having a Date implementation like every other freaking major language in the world.

Re: Date Selector of the Damned

2012-06-18 11:51 • by Neither Gilbert nor Sullivan (unregistered)
He was the very model of an enlightened modern-day senior web developer

Dammit. Now I've got The Pirates of Penzance running through my head. Thanks.

Re: Date Selector of the Damned

2012-06-18 11:51 • by KarelI (unregistered)
Fortunately he didn't realize there are 30-day months and leap years :-)

Re: All web developers?

2012-06-18 11:53 • by Bob (unregistered)
383348 in reply to 383340
Woah, sensitive type. Bit too close to the bone, huh?

Re: Date Selector of the Damned

2012-06-18 11:54 • by Mutt (unregistered)
People still use Experts Exchange?

Re: Date Selector of the Damned

2012-06-18 11:55 • by Tasty (unregistered)
383350 in reply to 383338
barfoo:
Obviously you lack creativity. The worse version would involve inputting the date in Julian and writing a routine to convert it to Gregorian.


I'd much rather use Julian Days than the Gregorian calendar. They're much more accurate.

Re: All web developers?

2012-06-18 11:56 • by bewbs (unregistered)
383351 in reply to 383340
you mad bro?

Re: Date Selector of the Damned

2012-06-18 11:57 • by ¯\(°_o)/¯ I DUNNO LOL (unregistered)
TRWTF is that he didn't ask // string to int pretty please

At least the year field is wide enough for Y10K.

Re: Date Selector of the Damned

2012-06-18 12:01 • by Anon (unregistered)
383353 in reply to 383349
// set StartYear to 2010 so we don't goof up the loop logic


I think that ship has sailed...

Re: Date Selector of the Damned

2012-06-18 12:05 • by anony-mouse (unregistered)
It's bad enough he had retarded practices, but he didn't have a logical understanding of programming.

I suppose GlobalVars.Day = parseInt($('#DaySelect').val()) would have been too easy; case statement clearly necessary.

Re: All web developers?

2012-06-18 12:14 • by D-Coder
383355 in reply to 383340
Patrick Bell:
Because web developers are the only programmers who write horribly mangled code, amirite? Please. And yet it is taboo to say that C/C++ have held the state of the art in software back by several decades due to their extreme low-level concepts and lack of portability?

<<snip>>

*plonk*

Sincerely,
Patrick
Work on C++ started in 1979. So it could not have "held the state of the art in software back by several decades".

Only by three decades.

So far.

Re: All web developers?

2012-06-18 12:15 • by Mason Wheeler
383356 in reply to 383340
Patrick Bell:
Because web developers are the only programmers who write horribly mangled code, amirite? Please. And yet it is taboo to say that C/C++ have held the state of the art in software back by several decades due to their extreme low-level concepts and lack of portability?


While you're right that C is a horrible language and should never have been allowed to inflict its descendants upon the world, particularly after 1989 when the Morris Worm taught us that it was completely unsuited to development in any environment that came with security requirements, that really doesn't have anything to do with today's article, and it doesn't make the code any less horrible.

Re: Date Selector of the Damned

2012-06-18 12:16 • by Nagesh
This code is no excuse for being in field of computer programming.

Re: Date Selector of the Damned

2012-06-18 12:22 • by qbolec (unregistered)
383359 in reply to 383345
ubersoldat:
This is why college education is broken. They teach you so many things, except to look at the API.


I would love to work in place that:
1. hires only graduates of CS as web developers
2. does not depend heavily on "designs" provided by Photo Shop artists as a GUI specs

until then, I must say, that sadly, but we have developed more than one date-picker "control" even though some us knew that there is a plugin for that.

JPEG-driven development is my everyday nightmare. I believe the problem is that JPEGs say 1000 words to upper managment, while software architects just say a lot of sophisticated words which are hard to comprehend.
What I believe is necessary is to develop a visual language in which architects could express their thoughts to managment. I am not talking about UML -- it's too complicated. Look for instance at the domain of real Architecture (that one which deals with buildings) : architects in that area olways provide visualisations, beautiful pictures, perspectives, and so on. CS lacks this kind of visual language :(

Re: Date Selector of the Damned

2012-06-18 12:33 • by myName (unregistered)
It could have been written at a place which doesn't allow the use of any third party software other than the approved list.

Re: Date Selector of the Damned

2012-06-18 12:44 • by C-Derb (unregistered)
I'm calling shenanigans.

There's no way you could have more than a week of web development experience and not have the thought ever cross your mind to simply start the select lists with <option value="0"></option>.

Re: Date Selector of the Damned

2012-06-18 12:48 • by shoeboy
I love this Mayan calendar implementation! 2013? There is no 2013!!!

Re: All web developers?

2012-06-18 12:51 • by Anon (unregistered)
383365 in reply to 383355
D-Coder:
Work on C++ started in 1979. So it could not have "held the state of the art in software back by several decades".

Only by three decades.

So far.

Wrong.

http://xkcd.com/1070/

Re: All web developers?

2012-06-18 12:54 • by M (unregistered)
383366 in reply to 383355
D-Coder:
Patrick Bell:
Because web developers are the only programmers who write horribly mangled code, amirite? Please. And yet it is taboo to say that C/C++ have held the state of the art in software back by several decades due to their extreme low-level concepts and lack of portability?

<<snip>>

*plonk*

Sincerely,
Patrick
Work on C++ started in 1979. So it could not have "held the state of the art in software back by several decades".

Only by three decades.

So far.


Cue the obligatory xkcd reference, which happens to be today's comic!

http://xkcd.com/1070/

Re: Date Selector of the Damned

2012-06-18 12:55 • by Dave (unregistered)
383367 in reply to 383345
ubersoldat:
TRWTF is JavaScript for not having a Date implementation


Did you really just say that?

Re: All web developers?

2012-06-18 12:57 • by Anon (unregistered)
383368 in reply to 383366
M:

Cue the obligatory xkcd reference, which happens to be today's comic!

http://xkcd.com/1070/

TRWTF is people who claim to be programmers but don't read xkcd every day.

Re: Date Selector of the Damned

2012-06-18 13:03 • by C-Derb (unregistered)
383369 in reply to 383364
shoeboy:
I love this Mayan calendar implementation! 2013? There is no 2013!!!


I thought the same thing. Why go to all the trouble of dynamically populating the the Year selector when the "validation" is limited to 2011 and 2012, unless you know something?


// set query filter based on selected value
switch (GlobalVars.SelectedIndex) {
case 2:
{
GlobalVars.Year = '2011';
break;
}
case 3:
{
GlobalVars.Year = '2012';
break;
}
}

Re: Date Selector of the Damned

2012-06-18 13:19 • by Mike (unregistered)
happily and cluelessly producing oceans of spaghetti code so bad that even Olive Garden wouldn't serve it

That would have been wittier without "code".

Re: All web developers?

2012-06-18 13:25 • by Karel (unregistered)
383371 in reply to 383340
Hi Patrick,

Nice one and you're right.
But that's no reason to leave. There is good stuff too here.

Cheers

Re: Date Selector of the Damned

2012-06-18 13:39 • by Nagesha (unregistered)
I am telling that expertsexchange is site what is producing the very very best results in Hyderabad.

Re: Date Selector of the Damned

2012-06-18 13:42 • by n_slash_a (unregistered)
The ONLY good thing about that code is at least the comments were polite
Original Article:

// string to int please
GlobalVars.SelectedIndex = parseInt(GlobalVars.SelectedIndex);

Re: Date Selector of the Damned

2012-06-18 13:43 • by wonk (unregistered)
383375 in reply to 383349
Mutt:
People still use Expert Sexchange?


FTFY

Re: Date Selector of the Damned

2012-06-18 13:52 • by dogmatic (unregistered)
The real wtf is that he doesn't take into account for leap years. Amiright?

Re: All web developers? Well, all is a bit harsh

2012-06-18 13:52 • by TurdCrawler (unregistered)
383377 in reply to 383344
mrfr0g:
Patrick Bell:
Because web developers are the only programmers who write horribly mangled code, amirite? Please. And yet it is taboo to say that C/C++ have held the state of the art in software back by several decades due to their extreme low-level concepts and lack of portability?

Dear Daily WTF,

I came for the lulz, and left because of the sickening elitism among your submitters and commentors whose lives are now so devoid of meaning that the only pleasure they get is derived from heckling the less gifted.

Enjoy your passive aggressive snickering and your tiny cubicles while you hide from doing real work.

*plonk*

Sincerely,
Patrick


Hey congratulations! You just got the point of this website, to make fun of poorly written code. Today it is a javascript WTF, tomorrow it might be c/c++, Java, classic ASP, or really anything else "code" related.

I am a Web Developer, have been for a number of years and I can say with certainty that the code posted today is terrible, and deserves to be made fun of.


Dang! Before he left, we should have asked for some of his well-written code (to make fun of while we hide in our cubicles avoiding work)!

Re: Javascript?

2012-06-18 13:55 • by dogmatic (unregistered)
383378 in reply to 383337
Kasper:
There is not much reason to be using javascript in the first place. That page could have worked just as fine without any javascript. The only thing that javascript could really do for such a page is to present an error message to the user slightly faster, if the input is inconsistent (like specifying the 30th of February or such).

You are going to need validation on the server side anyway. As a user I'd much rather see a solution that only validates on the server side than one, that does a poor job of validating on the client side.


You must provide both server side and client side evaluation else run the risk of being branded a lazy developer.

Re: Date Selector of the Damned

2012-06-18 14:08 • by qwerty (unregistered)
// get current date and time from server
$.getJSON('/GetDateTime)', null, function (data) {


wow.

Re: All web developers?

2012-06-18 14:26 • by F (unregistered)
383380 in reply to 383368
Anon:
M:

Cue the obligatory xkcd reference, which happens to be today's comic!

http://xkcd.com/1070/

TRWTF is people who claim to be programmers but don't read xkcd every day.


TRWTF is people who claim to be readers of xkcd but haven't noticed it only appears three times a week.

Re: All web developers?

2012-06-18 14:26 • by F (unregistered)
383381 in reply to 383368
Anon:
M:

Cue the obligatory xkcd reference, which happens to be today's comic!

http://xkcd.com/1070/

TRWTF is people who claim to be programmers but don't read xkcd every day.


TRWTF is people who claim to be readers of xkcd but haven't noticed it only appears three times a week.

Re: Date Selector of the Damned

2012-06-18 14:30 • by Tom (unregistered)
That is an elegant and beautiful solution to a completely non-existent problem.

Re: Javascript?

2012-06-18 14:32 • by Darth Paul (unregistered)
383383 in reply to 383343
Tim:
Once you understand that, client-scripted validation is merely sugar to help the babies who don't know how to enter dates yet.


Or tar to hinder those who do.

Re: All web developers?

2012-06-18 14:32 • by KattMan
383384 in reply to 383381
F:
Anon:
M:

Cue the obligatory xkcd reference, which happens to be today's comic!

http://xkcd.com/1070/

TRWTF is people who claim to be programmers but don't read xkcd every day.


TRWTF is people who claim to be readers of xkcd but haven't noticed it only appears three times a week.


Who cares how often it appears, they still read it everyday. Just like I come here everyday but it isn't updated every day.

Re: Date Selector of the Damned

2012-06-18 14:32 • by xtremezone
To be fair, most date selector UIs are incredibly slow and clunky to use. They are mostly useful for figuring out a date that you aren't sure about, but they're often quite painful. If you already have the date in mind then typing it is usually far easier. A smart text box that turns anything you type into a known date would be handy. Better than a "date picker", as they're generally called. A calendar view is useful for associating days with weeks or counting days, but not much else...

Also, JavaScript reliance is evil. Also, that code is really bad...
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment