Date Selector of the Damned

  • GettinSadda 2012-06-18 11:20
    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!
  • snoofle 2012-06-18 11:26
    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?
  • Nagesh 2012-06-18 11:27
    I see no problem with this code. It is a work of art!
  • jonny_q 2012-06-18 11:33
    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.
  • DWalekr59 2012-06-18 11:34
    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".".
  • Kasper 2012-06-18 11:35
    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.
  • barfoo 2012-06-18 11:35
    Obviously you lack creativity. The worse version would involve inputting the date in Julian and writing a routine to convert it to Gregorian.
  • Chronomium 2012-06-18 11:36
    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.
  • Patrick Bell 2012-06-18 11:37
    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
  • Anon 2012-06-18 11:39
    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.
  • An on 2012-06-18 11:39
    > // 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...
  • Tim 2012-06-18 11:48
    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.
  • mrfr0g 2012-06-18 11:48
    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
  • ubersoldat 2012-06-18 11:49
    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.
  • Neither Gilbert nor Sullivan 2012-06-18 11:51
    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.
  • KarelI 2012-06-18 11:51
    Fortunately he didn't realize there are 30-day months and leap years :-)
  • Bob 2012-06-18 11:53
    Woah, sensitive type. Bit too close to the bone, huh?
  • Mutt 2012-06-18 11:54
    People still use Experts Exchange?
  • Tasty 2012-06-18 11:55
    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.
  • bewbs 2012-06-18 11:56
    you mad bro?

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

    At least the year field is wide enough for Y10K.
  • Anon 2012-06-18 12:01
    // set StartYear to 2010 so we don't goof up the loop logic


    I think that ship has sailed...
  • anony-mouse 2012-06-18 12:05
    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.
  • D-Coder 2012-06-18 12:14
    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.
  • Mason Wheeler 2012-06-18 12:15
    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.
  • Nagesh 2012-06-18 12:16
    This code is no excuse for being in field of computer programming.
  • qbolec 2012-06-18 12:22
    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 :(
  • myName 2012-06-18 12:33
    It could have been written at a place which doesn't allow the use of any third party software other than the approved list.
  • C-Derb 2012-06-18 12:44
    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>.

  • shoeboy 2012-06-18 12:48
    I love this Mayan calendar implementation! 2013? There is no 2013!!!
  • Anon 2012-06-18 12:51
    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/
  • M 2012-06-18 12:54
    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/
  • Dave 2012-06-18 12:55
    ubersoldat:
    TRWTF is JavaScript for not having a Date implementation


    Did you really just say that?
  • Anon 2012-06-18 12:57
    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.
  • C-Derb 2012-06-18 13:03
    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;
    }
    }
  • Mike 2012-06-18 13:19
    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".
  • Karel 2012-06-18 13:25
    Hi Patrick,

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

    Cheers
  • Nagesha 2012-06-18 13:39
    I am telling that expertsexchange is site what is producing the very very best results in Hyderabad.
  • n_slash_a 2012-06-18 13:42
    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);
  • wonk 2012-06-18 13:43
    Mutt:
    People still use Expert Sexchange?


    FTFY
  • dogmatic 2012-06-18 13:52
    The real wtf is that he doesn't take into account for leap years. Amiright?
  • TurdCrawler 2012-06-18 13:52
    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)!
  • dogmatic 2012-06-18 13:55
    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.
  • qwerty 2012-06-18 14:08
    // get current date and time from server
    $.getJSON('/GetDateTime)', null, function (data) {


    wow.
  • F 2012-06-18 14:26
    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.
  • F 2012-06-18 14:26
    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.
  • Tom 2012-06-18 14:30
    That is an elegant and beautiful solution to a completely non-existent problem.
  • Darth Paul 2012-06-18 14:32
    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.
  • KattMan 2012-06-18 14:32
    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.
  • xtremezone 2012-06-18 14:32
    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...
  • Unicorn #8157 2012-06-18 14:34
    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.

    What are you talking about? It happens eight times a week, sometimes only seven. Three at xkcd.com and five time here. Or four when they miss an update here.
  • shoeboy 2012-06-18 14:47
    Clearly a person would only leave out future years only if they new what the future has in store!
    C-Derb:
    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;
    }
    }
  • herby 2012-06-18 14:51
    Just a note: If this were back in (say) 1997 or so, there would have been a big debate as to weather 2000 was a leap year or not.

    When asked the question "What day is it?", the proper response is (as any programmer knows) "Today!", sometimes "Monday" will suffice!
  • D-Coder 2012-06-18 14:57
    Anon:
    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/
    I regret that I snipped too much and phrased my point so subtly, since you missed it. Here it is, in one-syllable words (except for "C++"):

    "Lots of us think C++ sucks too."
  • Matt Westwood 2012-06-18 14:58
    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...


    +1

    A switched-on clueful app offers both options for each date selector.
  • mag 2012-06-18 15:18
    "Let his tale be a cautionary one, that a man must first learn the alphabet before he aspires to be Shakespeare."

    Trying to cut down the vast difference between the ideas in this analogy cuts out wayyyyyyyyyyyyyyyyyyyyy too much.

    Is hjbdsfuyhbsdnaoiudbasodfnasldiugasasldunfasd Shakespearean enough?

    Sorry to be pedantic, but it's quotes like the one supplied that make people think it really is that easy... and then they become web developers.
  • iMalc 2012-06-18 15:22
    Why complain? This code is a dream come true if you ever wished that Feburary had 31 days!
  • minion 2012-06-18 15:26
    An on:
    > // 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...


    True, even just being forced to be a *user* of a SAP installation makes you want to start worshipping the devil, so I assume that the poor programmer had been brainwashed by SAP and therefore had to produce shite code
  • Matt 2012-06-18 15:31
    Submitter really needs to learn that holding in his feelings is unhealthy.
  • MYSELF 2012-06-18 16:22
    Neither Gilbert nor Sullivan:
    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.

    Is Penzance near Solaia? Or Connected with Penz Oil? Inquiring minds need to know!
  • Fake Fake Nagesh 2012-06-18 16:29
    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!


    That sounds to me like a code challenge. ;)
  • linepro 2012-06-18 16:32
    Chronomium:
    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.


    That would be because only one inane country in the world thinks that the date order is mm/dd/yyyy; the rest of us spend hours coding arround the "default"
  • stew 2012-06-18 16:46
    Patrick Bell:
    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?


    Actually, one of the original design goals of C was to allow for portable code.

    Not to mention that many (all?) of the "RAD" languages in use today -- Ruby, Python, PHP, Perl, etc., etc., etc., -- are implemented in the very language that "held the state-of-the-art in software back by several decades."

    But obviously I'm being elitist now, so I'll just get back to not doing work....
  • Tyler 2012-06-18 16:56
    *Looks at tdwtf code*
    *Looks back at code-base*

    *Sighs* this one's a little too close to a standard for a set of old deprecated code that has yet to be fully cleaned out.
  • Gunslinger 2012-06-18 17:02
    The Real WTF is insulting Olive Garden.
  • RedFeather 2012-06-18 17:10
    Chronomium:
    Why is the order month/day/year?
    Presumably, the programmer is from the US, where month/day/year is the preferred order.
  • Alexandros Katechis 2012-06-18 17:24
    I'm sure we can add a whole new level of WTF-ness by incorporating some XML.
  • Maurits 2012-06-18 17:43
    He was the very model of an enlightened modern-day senior web developer


    Prosody fail.

    "He was the very model of a senior web developer..." is OK.
    "He was the very model of a modern-day developer..." is OK.

    I'm having trouble getting "enlightened" in there.
  • wou 2012-06-18 17:56
    Chronomium:
    Why is the year box about 40% wider than the other two?

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

    ....
    Rather than self-commenting code, the decision was made to use self-coding comments
  • Peter 2012-06-18 17:59
    Alex Papadimoulis:
    ...happily and cluelessly producing oceans of spaghetti code so bad that even Olive Garden wouldn't serve it.


    That is now one of my top ten favorite quotes ever. Love it!
  • Billy Gate 2012-06-18 17:59
    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
    Meh - another Web Developer who thought he could play with the big boys.....
  • Scrummy 2012-06-18 18:13
    This looks to be a project desperately in need of Agile. If they were pair programming, such an abomination of run-on Javascript would never have happened.
  • shi 2012-06-18 18:48
    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.
    I agree to a large degree. When I was at Uni we spent a lot of time re-inventing the wheel (data structures in particular) in Java. While it is good to understand data structures, I think peoiple need to be encouraged to use or extend existing ones that were made by smarter people where possible rather than making their own linked list.

    Don't get me wrong, I understand that creating a linked list helps teach how a linked list works, but if you want people to understand 'under the hood' teach them in C....If you teach people that they can make Data Structures in Java, then the freshman graduates will think that they should always make their own DS. I'm near certain that few if any of them would be able to develop even the simplest Data Structure as efficiently as the people who created the Containers in java.util

    Unfortunately, I think if things (not just in CS) were taught properly, too many students would complain courses are too hard and there's be low attendance.....
  • spelley 2012-06-18 18:51
    That code: complete and utter abomination.

    Submitter's assumption anyone doing web development is inherently more stupid than a programmer who doesn't do web development: elitist and misinformed.

    2 WTFs for price of 1 today.
  • fheiopas 2012-06-18 18:53
    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.
    TRWTF is comments that appear two times a day
  • Sayer 2012-06-18 18:54
    stew:
    Patrick Bell:
    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?


    Actually, one of the original design goals of C was to allow for portable code.

    Not to mention that many (all?) of the "RAD" languages in use today -- Ruby, Python, PHP, Perl, etc., etc., etc., -- are implemented in the very language that "held the state-of-the-art in software back by several decades."

    But obviously I'm being elitist now, so I'll just get back to not doing work....


    Fair enough, but we could have absolutely done without all the masturbatory programmer hipster arsehattery in the intro to the article. A web developer can write shitty code without automatically making all the rest more prone to it.

    vulputate: Amputaing foxes?
  • Mitch 2012-06-18 18:58
    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...
    Yes indeeedy!!!

    I much prefer being able to type dd <tab> mm <tab> yyyy (or even simply ddmmyyyy than having to select anything. The bank I use makes this particularly cumbersome - it allows typing of dates, but requires the user enter the separator (and also supports one of the calendar pickers). Personally, if I want to search for all transactions since July 2008 it is a lot quicker for me to use the Numeric KeyPad to enter 01072009 than to fiddle around skipping months and years in a Calendar picker.....
  • Zaphod 2012-06-18 19:00
    I had to fill in a USA Visa Waiver

    goto https://esta.cbp.dhs.gov/esta/
    & follow the Apply for Visa

    eventually you get to

    https://esta.cbp.dhs.gov/esta/application.html?execution=e1s3

    Try doing a view source on this beauty !

    I expect there are legal requirements for the page format .... barfff .....
  • Jim 2012-06-18 19:10
    Sayer:
    stew:
    Patrick Bell:
    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?


    Actually, one of the original design goals of C was to allow for portable code.

    Not to mention that many (all?) of the "RAD" languages in use today -- Ruby, Python, PHP, Perl, etc., etc., etc., -- are implemented in the very language that "held the state-of-the-art in software back by several decades."

    But obviously I'm being elitist now, so I'll just get back to not doing work....


    Fair enough, but we could have absolutely done without all the masturbatory programmer hipster arsehattery in the intro to the article. A web developer can write shitty code without automatically making all the rest more prone to it.

    vulputate: Amputaing foxes?
    The article starts with "It's no secret web developers are generally considered...."
    This suggests an attitude toward the WebDev, not an attack insisting it's true.

    When it follows up with:
    "...and with good reason"
    It's still not attacking all WebDev's (if you read the rest of it) it's merely highlighting that as the internet exploded on the scene and everyone wanted a website, this area of development got flooded with script kiddies who thought they could....

    It does not suggest that ALL Web Developers are incomeptent idiots, it merely highlights a presumption that this is the case because of the disproportionate number of Script Kiddies in Web Development compared to the in other Programming roles.


    For the record, I have worked with a lot of Muppets in Application Development too and perhpas they're just lucky that application source is not so readily available for people to inspect. But...from my experience about 2/3 of programmers outside of Web Development are useless/incompetent/dumb/underqualified/whatever (yes THAT many). In Web Development this figure seems a lot closer to 4/5 or more.....
    IT is flooded with useless incompetence, however I think even Blind Freddie in his naivest hour would agree that Web Development seems to attract a lot more than it's fair share - perhaps this is because it is easy to make things look really flash so business people are impressed.....
  • thaaanos 2012-06-18 20:15
    // string to int please

    It's a WOMAN!
  • James A. Donald 2012-06-18 22:37
    Unfortunately my deadline was yesterday, and there is something about the web environment that makes it a lot easier just copy a pile of old code for some very similar pages and functionality, and tweak it as necessary for some new pages and new functionality, rather than factor out the commonality of function.

    After several generations of such copy and hack, the code gets mighty strange.
  • Nobody 2012-06-18 22:39
    thaaanos:
    // string to int please

    It's a WOMAN!


    Or a Canadian.
  • Newbie 2012-06-18 22:56
    I'm a fairly green coder with not that much experience in anything yet but I have set up a fairly basic UI in java one time. So when I first looked at the window I thought to myself "ok, I'd have used a typed input instead of choice lists or whatever they are called.

    Then I scrolled down to see the code and reacted like this.

    wtf?

    Scroll down.

    wtf!

    WTF?!

    Scroll down.

    WHAT THE FUCK?!

    WHYYYY?!

    This from a guy having trouble finding a coding job due to lack of experience. :/
  • Luiz Felipe 2012-06-18 23:07
    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.


    I agree with you.
    Also, Gregorian calendar is the TRWTF.
  • Luiz Felipe 2012-06-18 23:09
    James A. Donald:
    Unfortunately my deadline was yesterday, and there is something about the web environment that makes it a lot easier just copy a pile of old code for some very similar pages and functionality, and tweak it as necessary for some new pages and new functionality, rather than factor out the commonality of function.

    After several generations of such copy and hack, the code gets mighty strange.


    You are failing in not letting the less succefull code die.
    Copy and past everywhere, but only take the best candidate to next project.
    Its called evolution, if it works for nature, then must work for you.
  • Luiz Felipe 2012-06-18 23:11
    qbolec:
    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 :(


    Problem is that CS courses have too much math and little hands-on coding with someone that actually codes. The works coders i knows are teachers from academy.
  • Kuba 2012-06-18 23:28
    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?
    Let me take you up on it. I have a bunch of C written for Z8 Encore!, some 20k lines worth. I recompiled those projects using gcc 4.2 with a bunch of command-line defines to massage types to retain their sizes and to nop-out near/far specifiers. Not only does it compile, but it even passes most of the unit tests -- those were coded to run on simulator anyway, so they don't care much for chip's peripherals.

    IOW: Yeah, if you don't educate yourself and are sloppy, then yes, you are holding back "state of the art" whatever language you end up using.
  • Shinobu 2012-06-19 00:02
    It's an especially bad analogy since Shakespeare was probably a notoriously bad speller. (Although some people claim his editors were at fault since we don't have much handwritten material and others say quite reasonably that even if he was, people at the time wouldn't have minded as much since the standards of the time were lower.)
  • YouHerpYouSaveYouDerpYouSave 2012-06-19 01:31
    All I see when I look at this code is responsive web design!

    This good man used only percentages for width and height! Ok fine the inline styling is not exactly state of the art and I'm not entirely sure why you would need a height style on an input element but RESPONSIVE WEB!

    NODEJS NON-BLOCKING RESPONSIVE WEB 2.0!1!!!

    Any questions?

    Captcha: abbas - Members of ABBA. Obvious...
  • d 2012-06-19 02:23
    snoofle:
    I know *nothing* of web development...
    That's OK, apparently, web developers don't either.
  • Aargle Zymurgy 2012-06-19 02:33
    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.



    Well put. I'm going to add that the people we are making fun of aren't "less gifted" as Patrick put it. They are, in fact, complete incompetents who refuse to learn or improve and arrogantly take money from companies only because matching incompetent Dibertesque management can't tell shizz from Shinola when it comes to programming. We need a "dailymanagementwtf.come" to cover those stories, though.

    Case in point (and this probably should get its own page, but wtf):

    When I was teaching C years back, my first assignment was basically to code and compile "Hello, world." It wasn't a real challenge, but it got the students learning the dev environment without actually having to program. One student diligently turned in the first assignement. He was a programmer for a local company who was trying to take advantage of company-sponsored training.

    Now, my tests were always 4 parts: 1) true-false 2) multiple-choice 3) fill-in-the-blank and 4) Essay. 2/3 of the test was #1 and #2. This student's test was so bad, random chance would have scored better. I asked my wife to take the test. She barely knew how to turn on a computer at the time and was going to refuse, but I insisted. She outscored this "professional" programmer even though she never attended the class.

    The semester ended and his final was as bad as the mid-term. I gave him the F he deserved. A week later, after he got his grades, I got a panicked phone call from him. He didn't understand why he got an F. I said, "you turned in only the first assignment, but that was only 1 of 12. As I discussed the first day, I consider practical programming more important than the tests. Assignments were 2/3 of your grade. Did you hear and read something the other students didn't?" To my shock, his reply was something I never expected: "but I thought my test grades would carry me."

    Come to find out, he was not a US citizen, but here on a work visa. After he failed my course, his company discovered that he didn't know how to program at all. He was facing firing and deportation at the same time.

    Did I feel sorry for his family? Yes, I did. Did I blame myself? No, I didn't. Did I blame him for pretending to be competent and taking other peoples' money and give them nothing in return? Yes, definitely. Though, in retrospect, I'd have canned his manager(s) too. Incompetent worker and management too incompetent to know the difference. But as I said above, we need another website.

    thedailywtf isn't about "less gifted" people. It's about the intolerable and incompetent scammers that, through either intent or ignorance, equate themselves with those of us who give a damn about our work.

    Patrick, your *plonk* is a *plink*. Someone thought you self-identified as the creator of the problem. That's so unlikely that it boggles the mind, but the humor stands. If you really don't get it, then you're one of the con-men we're all nattering about.

    'nuff said.

    AZ
  • toshir0 2012-06-19 02:52
    alert('You Must Choose Another Fucking Job!');

  • flob9 2012-06-19 03:04
    KattMan:
    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.


    TRWTF is people not using RSS feeds.
  • pants 2012-06-19 04:16
    The problem with text dates is you never know if the user is going to input dd/mm/yyyy, mm/dd/yyyy, or ISO standard yyyy/mm/dd, or worse - nn/nn/nn (which could be any of the previous formats with two digit years).

    A proper system would use a sane date format like the interleaved dymydymy format.

    captcha: usitas - usitas an example of how to do it.
  • Thegoryone 2012-06-19 05:06
    Why allow standard dates? What if the user lives his life in posix time? That's some elitist pigeonholing there, expecting him to know it's May the 14th in 1266.

    captcha: Opto. From greek for visible (And basis for the Roman Optio. I'm an officer now!)
  • pantsman 2012-06-19 05:19
    TRWTF is Experts Exchange. Any self-respecting web monkey knows that Stack Overflow is the place to flood with "please fix teh codes" questions on basic scripting/HTML/CSS.
  • Annon Too 2012-06-19 07:51
    The frist words out of my mouth when reading this article.... Holy Shit!

    I choose to believe that this was not written by a human being, but generated from a self replicating evil loop.
  • Sayer 2012-06-19 09:03
    Aargle Zymurgy:
    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.



    Well put. I'm going to add that the people we are making fun of aren't "less gifted" as Patrick put it. They are, in fact, complete incompetents who refuse to learn or improve and arrogantly take money from companies only because matching incompetent Dibertesque management can't tell shizz from Shinola when it comes to programming. We need a "dailymanagementwtf.come" to cover those stories, though.

    Case in point (and this probably should get its own page, but wtf):

    When I was teaching C years back, my first assignment was basically to code and compile "Hello, world." It wasn't a real challenge, but it got the students learning the dev environment without actually having to program. One student diligently turned in the first assignement. He was a programmer for a local company who was trying to take advantage of company-sponsored training.

    Now, my tests were always 4 parts: 1) true-false 2) multiple-choice 3) fill-in-the-blank and 4) Essay. 2/3 of the test was #1 and #2. This student's test was so bad, random chance would have scored better. I asked my wife to take the test. She barely knew how to turn on a computer at the time and was going to refuse, but I insisted. She outscored this "professional" programmer even though she never attended the class.

    The semester ended and his final was as bad as the mid-term. I gave him the F he deserved. A week later, after he got his grades, I got a panicked phone call from him. He didn't understand why he got an F. I said, "you turned in only the first assignment, but that was only 1 of 12. As I discussed the first day, I consider practical programming more important than the tests. Assignments were 2/3 of your grade. Did you hear and read something the other students didn't?" To my shock, his reply was something I never expected: "but I thought my test grades would carry me."

    Come to find out, he was not a US citizen, but here on a work visa. After he failed my course, his company discovered that he didn't know how to program at all. He was facing firing and deportation at the same time.

    Did I feel sorry for his family? Yes, I did. Did I blame myself? No, I didn't. Did I blame him for pretending to be competent and taking other peoples' money and give them nothing in return? Yes, definitely. Though, in retrospect, I'd have canned his manager(s) too. Incompetent worker and management too incompetent to know the difference. But as I said above, we need another website.

    thedailywtf isn't about "less gifted" people. It's about the intolerable and incompetent scammers that, through either intent or ignorance, equate themselves with those of us who give a damn about our work.

    Patrick, your *plonk* is a *plink*. Someone thought you self-identified as the creator of the problem. That's so unlikely that it boggles the mind, but the humor stands. If you really don't get it, then you're one of the con-men we're all nattering about.

    'nuff said.

    AZ


    Fantastic story, but not his point. The elitism he's talking about isn't the part where the bad code is made fun of. The part that rubbed him the wrong way (and me) is the part where it's implied that web programmers are all knuckle dragging halfwits when compared to "true" programmers.

    "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."

    That sounds damning, except that describes nearly every bad self taught programmer I've ever met, many of whom started with a shelf of Borland C++ books and a pirated version of the compiler. Does my anecdotal evidence trump his?

    This very site is proof that jacktards exist in every aspect of coding across the board. The perception that web developers are worse stems from the same type of reasoning that causes PS3 fanboys and XBox fanboys to get into fistfights.
  • Anon 2012-06-19 09:04
    'A programming language is only ever as bad as your lack of understanding of it.'

    The reason why Javascript is percieved as a 'bad' language is because there are so many incompetent people in the field. Anyone who can copy&paste can create a website and put it online. But that does not mean it's impossible to write good code. Just look at all the google webapps.
  • dgvid 2012-06-19 09:28
    How is it that after 99 comments, including several mocking JavaScript, C, and C++, that no one has pointed out that this awful code was obviously written by a VB programmer? I mean, look at the coding style. Look at the capitalized names! This is an example of someone trying to make a web page and JavaScript into Windows Forms and VB. There's the root of the problem.
  • n9ds 2012-06-19 09:52
    Gunslinger:
    The Real WTF is insulting Olive Garden.

    Have you actually eaten at Olive Garden??
  • Vendakka Puli, Esq. 2012-06-19 09:53

    CEASE AND DESIST DEMAND
    Pursuant to Title 17 of the United States Code

    Dear TDWTF:
    This law firm represents Rajendra Kumar. If you are represented by legal counsel, please direct this letter to your attorney immediately and have your attorney notify us of such representation.

    We are writing to notify you that your unlawful copying of Kumar Associates MasterDate™ Widget infringes upon our client’s exclusive copyrights. Accordingly, you are hereby directed to:

    CEASE AND DESIST ALL COPYRIGHT INFRINGEMENT.
    Rajendra Kumar is the owner a copyright in various aspects of Kumar Associates MasterDate™ Widget. Under United States copyright law, Rajendra Kumar’s copyrights have been in effect since the date that Kumar Associates MasterDate™ Widget was created. All copyrightable aspects of Kumar Associates MasterDate™ Widget are copyrighted under United States copyright law.

    It has come to our attention that you have been copying Kumar Associates MasterDate™ Widget. We have copies of your unlawful copies to preserve as evidence. Your actions constitute copyright infringement in violation of United States copyright laws. Under 17 U.S.C. 504, the consequences of copyright infringement include statutory damages of between 750 and 30,000 rupis per work, at the discretion of the court, and damages of up to 150,000 rupis per work for willful infringement. If you continue to engage in copyright infringement after receiving this letter, your actions will be evidence of “willful infringement.”

    We demand that you immediately (A) cease and desist your unlawful copying of Kumar Associates MasterDate™ Widget and (B) provide us with prompt written assurance within ten (10) days that you will cease and desist from further infringement of Rajendra Kumar’s copyrighted works.
    If you do not comply with this cease and desist demand within this time period, Rajendra Kumar is entitled to use your failure to comply as evidence of “willful infringement” and seek monetary damages and equitable relief for your copyright infringement. In the event you fail to meet this demand, please be advised that Rajendra Kumar has asked us to communicate to you that it will contemplate pursuing all available legal remedies, including demanding satisfaction, seeking monetary damages, injunctive relief, and an order that you pay court costs and attorney’s fees. Your liability and exposure under such legal action could be considerable.

    Before taking these steps, however, my client wished to give you one opportunity to discontinue your illegal conduct by complying with this demand within ten (10) days. Accordingly, please sign and return the attached Agreement within ten (10) days to

    Singh, Puli, Patel, Patel, Patel, & Patel
    Attorneys at Law
    Road No. 1
    Banjara Hills Hyderabad
    Andra Pradesh, India

    If you or your attorney have any questions, please contact me directly.
    Sincerely,
    Vendakka Puli, Esq.

  • Axeman 2012-06-19 10:46
    My thoughts exactly.
  • Axeman 2012-06-19 10:47
    If it works, use it for now then replace it later, have a code review and quit whining. Duh.
  • PiisAWheeL 2012-06-19 10:52
    Anon:
    'A programming language is only ever as bad as your lack of understanding of it.'

    The reason why Javascript is percieved as a 'bad' language is because there are so many incompetent people in the field. Anyone who can copy&paste can create a website and put it online. But that does not mean it's impossible to write good code. Just look at all the google webapps.
    The reason javascript is percieved as a bad language is because it doesn't behave the same way a lot of other languages behave when givin equivelent code. Its the unpredictibility that causes the creation of new curse words, loss of hair, and simple anger, that makes people hate the language.
  • TheSHEEEP 2012-06-19 11:00
    iMalc:
    Why complain? This code is a dream come true if you ever wished that Feburary had 31 days!


    Yeah, I also didn't notice any check if the date entered makes any sense.

    But maybe I was blinded by all the other horrible things in there.
  • stew 2012-06-19 11:06
    Sayer:
    The part that rubbed him the wrong way (and me) is the part where it's implied that web programmers are all knuckle dragging halfwits when compared to "true" programmers.


    The thing that strikes me odd about the great Wrong that's apparently been done to web developers here is, where are you guys whenever a PHP or VB example is posted and everyone piles on? Presumably, in the pecking order of programmers, those guys must obviously lie somewhere below web developers.

    Of course, "Patrick Bell" doesn't help out his "I'm a real programmer too!" creds by fundamentally mischaracterizing and misunderstanding the C language and its central role in the world of software development. But since he's likely a troll, I'm just assuming that was intentional.

    The indignation also ignores the fact that the OP describes himself as a web developer, and that while his opening sentence may smack of elitism, everything he says by-and-large is true.
  • Anon 2012-06-19 11:38
    PiisAWheeL:
    Anon:
    'A programming language is only ever as bad as your lack of understanding of it.'

    The reason why Javascript is percieved as a 'bad' language is because there are so many incompetent people in the field. Anyone who can copy&paste can create a website and put it online. But that does not mean it's impossible to write good code. Just look at all the google webapps.
    The reason javascript is percieved as a bad language is because it doesn't behave the same way a lot of other languages behave when givin equivelent code. Its the unpredictibility that causes the creation of new curse words, loss of hair, and simple anger, that makes people hate the language.


    What you describe is my point exactly; lack of understanding of how the language works. Expecting a prototypal language to behave like a class based language is going to cause you a headache.
  • Jerry 2012-06-19 12:29
    Sayer:
    it's implied that web programmers are all knuckle dragging halfwits when compared to "true" programmers.
    They're not all halfwits. Just like the water isn't all in the ocean.
  • Sayer 2012-06-19 12:30
    stew:
    Sayer:
    The part that rubbed him the wrong way (and me) is the part where it's implied that web programmers are all knuckle dragging halfwits when compared to "true" programmers.


    The thing that strikes me odd about the great Wrong that's apparently been done to web developers here is, where are you guys whenever a PHP or VB example is posted and everyone piles on? Presumably, in the pecking order of programmers, those guys must obviously lie somewhere below web developers.

    Of course, "Patrick Bell" doesn't help out his "I'm a real programmer too!" creds by fundamentally mischaracterizing and misunderstanding the C language and its central role in the world of software development. But since he's likely a troll, I'm just assuming that was intentional.

    The indignation also ignores the fact that the OP describes himself as a web developer, and that while his opening sentence may smack of elitism, everything he says by-and-large is true.


    Fair enough. but as I've only just started posting comments last week, my response to the "where are you guys when..." is "elsewhere"

    The pecking order crack was nice though, so not a complete loss.
  • pantsman 2012-06-19 12:33
    Scrummy:
    This looks to be a project desperately in need of Agile. If they were pair programming, such an abomination of run-on Javascript would never have happened.


    True, since if they were pair programming, no actual code would get written while they repeatedly high-fived each other into a climax, saying things like, "Dude, awesome node.js t-shirt you're wearing today", and "Dude, totally dig the new Octocat sticker on your MBP"
  • dogmatic 2012-06-19 16:07
    Anon:
    'A programming language is only ever as bad as your lack of understanding of it.'

    The reason why Javascript is percieved as a 'bad' language is because there are so many incompetent people in the field. Anyone who can copy&paste can create a website and put it online. But that does not mean it's impossible to write good code. Just look at all the google webapps.


    Let's face it, js is not the best language. Perhaps it's not the worst, but it makes it harder than most languages to develop a large scale, maintainable app in a team environment. That being said, this is an awesome reference for those wishing to expand their mastery of js: http://eleventyone.done.hu/OReilly.JavaScript.The.Good.Parts.May.2008.pdf

    I have worked with js for many years and would love not to have to work with it ever again. Unfortunately it is now more popular than ever, so dig we must.
  • Kasper 2012-06-19 19:41
    dogmatic:
    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.
    For a software developer, laziness is a virtue. It is of course possible to be too lazy, but without at least a bit of laziness, you'll never be a good software developer.

    Even for those ashamed of their laziness, I don't think it is a good idea to hide it behind a lot of incompetence. Remember your javascript code is going to be visible to a lot more people than the code you run on the server side.

    Poor client side validation code will make people think you are incompetent and forgot the server side validation. Good client side validation code will make people think you know what you are doing and remember to check most things server side.
  • dogmatic 2012-06-19 21:32
    Kasper:
    dogmatic:
    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.
    For a software developer, laziness is a virtue. It is of course possible to be too lazy, but without at least a bit of laziness, you'll never be a good software developer.

    Even for those ashamed of their laziness, I don't think it is a good idea to hide it behind a lot of incompetence. Remember your javascript code is going to be visible to a lot more people than the code you run on the server side.

    Poor client side validation code will make people think you are incompetent and forgot the server side validation. Good client side validation code will make people think you know what you are doing and remember to check most things server side.


    Well obviously both your client side validation and server side validation should be 'good'. We validate on the server side to prevent hacking and bad data entering the db. We validate on the client side to make for a nice user experience. That's it. Just to give the user a better experience, meaning not having to see a page refresh. It seems trivial and redundant for a developer (it is), but it looks more professional and is one of the small things we do to please our clients and keep them coming back for more.

    Most developers don't care about UX as much as they should. Given the choice between a development company that makes beautiful, intuitive, poorly coded and possibly insecure web apps, and a development company that makes excellently coded, maintainable, secure, but ugly and difficult to use web apps the client will go with the former every time. So I try to do both. And if you work for someone who requests this redundant validation, perhaps you can step back and understand it's because they like money and want to keep making it.
  • uxor 2012-06-19 23:21
    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.


    wow. please don't apply for a job here
  • uxor 2012-06-19 23:31
    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.


    You mean the people who claim to be programmers but do read that junk every day?
  • Kasper 2012-06-20 05:58
    dogmatic:
    We validate on the server side to prevent hacking and bad data entering the db. We validate on the client side to make for a nice user experience. That's it. Just to give the user a better experience, meaning not having to see a page refresh.
    A solution like you describe is better than what you'd have if you used no javascript at all. As long as the javascript is done properly.

    Done properly means the server side code is written as if the javascript wasn't there in the first place. And when a user gets to the form, types in valid input, and submits, neither the user nor the server sees any difference between a browser with javascript enabled and one with javascript disabled.

    There is a high requirement for the quality of that javascript code, because not only is it in plain sight to the power users, and you will be judged on that. But also because before you even start writing the javascript code, you have a functional system. It takes just one stupid mistake in the javascript code where you cannot handle some corner case before you get into a situation where the system overall would have been more functional if you had not written any javascript code in the first place.

    I'm not trying to discourage such use of javascript. But only use it if you know exactly what you are doing. If you are going to cut corners, and most IT products do, then that javascript is an obvious corner to cut.

    dogmatic:
    It seems trivial and redundant for a developer (it is), but it looks more professional and is one of the small things we do to please our clients and keep them coming back for more.
    It is neither trivial nor redundant. Writing the same validation twice in two different languages does seem a bit redundant, so a system that can automatically generate both instances of the validation from a common source is a nice feature to have. It can also guarantee that the criteria is in fact identical.
  • pantsman 2012-06-20 06:24
    Duplicating your validation code client-side is old-school (even if you have some code-gen way to do it, which probably means you are forced to write your rules in some idiosyncratic DSL).

    You can send user input to the server while they are entering it, validate it server-side, dynamically update the page, and the user won't know the difference.
  • Beorn 2012-06-20 10:08
    Zaphod:
    I had to fill in a USA Visa Waiver

    goto https://esta.cbp.dhs.gov/esta/
    & follow the Apply for Visa

    eventually you get to

    https://esta.cbp.dhs.gov/esta/application.html?execution=e1s3

    Try doing a view source on this beauty !

    I expect there are legal requirements for the page format .... barfff .....


    I went through the whole visa thing some times ago. I think they deliberatly made it that way so that the weak-of-mind commit suicide before finishing the application.
  • Jockamo 2012-06-20 16:00
    The code is terrible, for sure, but Joe sounds like a dick.
  • Melissa Raulston 2012-06-20 23:27
    I see your Date Selector of the Damned and raise you the Email Script of Doom. 13,000 (YOU READ THAT RIGHT) lines of code to collect inputs from a fairly simple form and drop them into an email. I wept when I started reading that thing. A visit to their forum suggested that in order to get it to run,I should give RWE perms to the command prompt to IUSR. Is a severe beating warranted her?I should think so....

    Weeping.

    Melissa
  • TheSHEEEP 2012-06-21 03:46
    13,000? o.O

    That's.... o v e r .... 9 0 0 0 !
  • Robert 2012-06-21 04:35
    All you people complaining about the OP's "insults to web programmers" need to re-read that first paragraph again, and actually process his words before flying off the handle in an angry rant.

    He doesn't speak one single word of disparagement about web programmers in general; he's speaking to the reputation that the industry of web programming has developed because it does actually have an overabundance of bad programmers.

    My captcha, 'genitus', reminds me of the story of that guy with the 100lb balls. I did not need that reminder right before going to bed.
  • Sayer 2012-06-21 09:03
    Robert:
    All you people complaining about the OP's "insults to web programmers" need to re-read that first paragraph again, and actually process his words before flying off the handle in an angry rant.

    He doesn't speak one single word of disparagement about web programmers in general; he's speaking to the reputation that the industry of web programming has developed because it does actually have an overabundance of bad programmers.


    All this super accurate "well technically" arguing is funny because it always starts with: "He doesn't speak one single word of disparagement about web programmers in general" and without a hint of irony finishes with:"...it [i]does actually have an overabundance of bad programmers."[/i] All based on anecdotal evidence and confirmation bias on a site that contains plenty of evidence that bad code is every damn place. "Oh yeah?! well every one of them I've ever met has been..."

    Bonus points for the OP being "the one sane man" as well. It seems all the other web developers are the dumb ones, just like every second comment here declares the methodology assertions of the one above it stupid.


    Bob:C++ is ....

    Tim:Well actually no, because....

    Tim:Pfft! You're both idiots since...

    Tim:Dumbasses! You could do all that in a line of PERL...

    Mark: Don't you know anything?! It's Perl!...
  • Foo 2012-06-21 09:13
    qbolec:
    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 :(


    Wow, wouldn't like to hire your dream company.
    I'd like to work somewhere that hires only art and design grads as web designers, and doesn't hire 'web developers', but actual software developers - and the best of those are often not CS grads, but Maths or Physics grads.

    Websites designed by CS grads look like, well, open-source GUIs, with no usability.
    I've never found a problem with working from jpegs (with some notes about animations, etc) as GUI specs - though you _do_ need to make sure you've got examples for stuff like drop-downs, and clear descriptions of how animations work.
  • Altourus 2012-06-21 13:40
    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.


    Ehem

    Manditory

    Also why does askmit think that this is spam?
  • wbrianwhite 2012-06-21 14:57
    qwerty:
    // get current date and time from server
    $.getJSON('/GetDateTime)', null, function (data) {


    wow.


    Well the browser time could be totally wrong
  • Altourus 2012-06-21 15:06
    wbrianwhite:
    qwerty:
    // get current date and time from server
    $.getJSON('/GetDateTime)', null, function (data) {


    wow.


    Well the browser time could be totally wrong


    Also depending on your system settings the date returned could be unparsable server-side. We've had that one happen a few times.
  • wbrianwhite 2012-06-21 17:17
    Kasper:
    dogmatic:
    We validate on the server side to prevent hacking and bad data entering the db. We validate on the client side to make for a nice user experience. That's it. Just to give the user a better experience, meaning not having to see a page refresh.
    A solution like you describe is better than what you'd have if you used no javascript at all. As long as the javascript is done properly.

    Done properly means the server side code is written as if the javascript wasn't there in the first place. And when a user gets to the form, types in valid input, and submits, neither the user nor the server sees any difference between a browser with javascript enabled and one with javascript disabled.

    There is a high requirement for the quality of that javascript code, because not only is it in plain sight to the power users, and you will be judged on that. But also because before you even start writing the javascript code, you have a functional system. It takes just one stupid mistake in the javascript code where you cannot handle some corner case before you get into a situation where the system overall would have been more functional if you had not written any javascript code in the first place.

    I'm not trying to discourage such use of javascript. But only use it if you know exactly what you are doing. If you are going to cut corners, and most IT products do, then that javascript is an obvious corner to cut.

    dogmatic:
    It seems trivial and redundant for a developer (it is), but it looks more professional and is one of the small things we do to please our clients and keep them coming back for more.
    It is neither trivial nor redundant. Writing the same validation twice in two different languages does seem a bit redundant, so a system that can automatically generate both instances of the validation from a common source is a nice feature to have. It can also guarantee that the criteria is in fact identical.


    The model validation code in ASP.Net MVC beautifully does the same validations server side and client side (by automatically decorating the relevant fields with jquery recognizable validation attributes). One of the real selling points.
  • Guest 2012-06-22 02:17
    I once read a blog post by some guy claiming he tends to employ people that appear lazy. The reason being they think before doing anything to limit the actual work to a minimum. I think I see were he is coming from!
  • Danny Moules 2012-06-22 08:06
    Altourus:
    Ehem

    Manditory

    Also why does askmit think that this is spam?


    Comment's too short.

    ...................
  • moz 2012-06-23 08:27
    Altourus:
    Ehem

    Manditory

    Also why does askmit think that this is spam?

    Two words, both mis-spelt, and a link. I think it's spam, and that's after looking at the URL.
  • Melissa Raulston 2012-06-23 08:47
    I replaced it with 89 lines and some tweaks to the form itself.

    Tectite.com if you are interested in viewing this abomination for yourself....

    Melissa
  • Daniel Beardsmore 2012-06-23 19:20
    Melissa Raulston:
    I replaced it with 89 lines and some tweaks to the form itself.

    Tectite.com if you are interested in viewing this abomination for yourself....

    Melissa


    I love this bit (lines 8554–8560):


    /*** not sure what to do with this....
    if (isset($a_upload["error"]))
    //
    // there was an upload error
    //
    continue;
    ***/


    That's one mother of a script …
  • blowhole 2012-06-24 21:32
    $i_rand = mt_rand(0,16777215); // 16777215 is FFFFFF in hex

    gud 2 no
  • Musaran 2012-06-28 12:20
    // increment year
    
    StartYear++;
    What is the name for this, err... "design pattern" ?
    Parrot comments ?


    Oh, and iterating with the initial value... a WTF on a single name + operator, that it not easy to achieve.
  • Amerrickangirl 2012-06-28 13:26
    If the page was properly designed the user wouldn't even have the option to pick 30 days for February. A date picker should know how many days are in a given month.
  • No 2012-06-29 14:38
    That will probably work on someone's personal site in a year from now. Would a real site use that code? Not for at least 2+ years.
  • Cbuttius 2012-07-02 05:04
    Mutt:
    People still use Experts Exchange?


    or expert sex change depending on how you parse it
  • .I. 2013-11-10 09:20
    suck my dick bastard