• Anonymous (unregistered)

    Antidepressants and Javascript might SEEM to go well together, but...

  • SR (unregistered) in reply to Anonymous
    Anonymous:
    Antidepressants and Javascript might SEEM to go well together, but...

    But there aren't enought antidepressants to tackle this JavaScript?

  • Mike Caron (unregistered)

    If you learned anything about for loops by looking at that code, you're doing it wrong.

    Captcha: quis (yes, I am feeling a bit quisy)

  • (cs) in reply to Mike Caron

    That's the problem with Javascript - you can't hide from the world. With server side code you have a better chance of hiding.

    Must get back to my server side code...

  • (cs)

    That for loop is called a Speedup Loop.

  • Newb (unregistered)

    Mandatory summarization: Got paid to port bad code, found bad code.

  • teh jav (unregistered) in reply to Newb
    Newb:
    Mandatory summarization: Got paid to port bad code, found bad code.
    Like Mandatory Fun Day but less funny.
  • Anyone (unregistered) in reply to teh jav
    teh jav:
    Newb:
    Mandatory summarization: Got paid to port bad code, found bad code.
    Like Mandatory Fun Day but less funny.

    So like Mandatory Fun Day then :P ?

  • (cs)
    function isDigit(digit) { var charOk = "0123456789"; return !(charOk.indexOf(digit) == -1) }

    function isAlphaNumeric(digit) { var charOk = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; return !(charOk.indexOf(digit) == -1) }

    What is so bad about these two functions? Are they really WTF worthy?

    I could understand if either of the soft-coded strings were missing some digits or letters (respectively), but I must just be missing the WTF moment here.

  • SR (unregistered) in reply to Newb
    Newb:
    Mandatory summarization: Got paid to port bad code, found bad code.

    Well done. I should stop reading the stories and just wait for some joyless wonk to summarise it.

  • SR (unregistered) in reply to Beldar the Phantom Replier
    Beldar the Phantom Replier:
    function isDigit(digit) { var charOk = "0123456789"; return !(charOk.indexOf(digit) == -1) }

    function isAlphaNumeric(digit) { var charOk = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; return !(charOk.indexOf(digit) == -1) }

    What is so bad about these two functions? Are they really WTF worthy?

    I could understand if either of the soft-coded strings were missing some digits or letters (respectively), but I must just be missing the WTF moment here.

    JS has isNaN() and !isNaN() to do these things.

  • coven (unregistered)

    Oh c'mon. isDigit is not all that bad compared to:

    // isDecimal
    // Validates s as a decimal number within the decimal number system
    // Used in all pages which depend on multilingual JavaScripts with language output
     
    function isDecimal(s) {
      var j;
      for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        j = parseInt(c,10);
        if ((j >= 0) && (j <= 9)) continue;
        else return false;
      }
      return true;
    }
    
    // isInteger
    // Validates s as an integer within the decimal number system
    // Used in all pages which depend on multilingual JavaScripts with language output
     
    function isInteger(s) {
      var j;
      for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        j = parseInt(c,10);
        if ((j >= 0) && (j <= 9)) continue;
        else return false;
      }
      return true;
    }
    
  • Anonymously Yours (unregistered)

    I don't see an issue with this code. So what if there's a bit of redundancy and unusual customization specific to the task? It's easy to update without breaking anything.

    This code doesn't have any issues I can see. Okay, there's some function and procedure copying, but that makes tweaking it to the task easier. Plus updates won't break anything.

    Where the issue? I don't see it. Repetitious code isn't cluttered and making uncommented code specific to the task at hand has the upside of not breaking the other 80 places you put copies of it. Updates are easy and safe, you just have to read more.

    I don't see a WTF with this code. Who cares if there's a bit of redundancy and unusual customization specific to the job? It's simple to update without breaking anything.

    This script doesn't have any WTFs I can perceive. Yes, there's some code copying, but that makes tweaking it to the task easier. Plus changes won't break anything.

    Where the WTF? I can't find it. Repetitive work isn't cluttered, and making uncommented code specific to what you're working on has the upside of not breaking the other /* 80 */ 83 places you put copies of it. Updates are easy and safe, you just have more to read.

    I don't have a problem with this content. So when if there's a bit of redundancy and unusual customizing unique to the task? It's easy to break without updatinging anything.

    This source code doesn't have any visible probles. OK, there's some copying and pasting and pasting but that makes working it to task easier. Plus updates won't crash anything.

    Where your boggle? I don't see it. see it. Repetitious code isn't cluttered and making nd has the upside of not breaking the other /* 80 */ 23 places you put copies of it. Updates are easy and safe, you

  • The Lumberyard (unregistered)

    Heh heh - he said stripNumber - Heh Heh

    captcha: luctus - wtf is that?

  • ZP (unregistered) in reply to Anonymously Yours
    Anonymously Yours:
    I don't see an issue with this code. So what if there's a bit of redundancy and unusual customization specific to the task? It's easy to update without breaking anything.

    This code doesn't have any issues I can see. Okay, there's some function and procedure copying, but that makes tweaking it to the task easier. Plus updates won't break anything.

    Where the issue? I don't see it. Repetitious code isn't cluttered and making uncommented code specific to the task at hand has the upside of not breaking the other 80 places you put copies of it. Updates are easy and safe, you just have to read more.

    I don't see a WTF with this code. Who cares if there's a bit of redundancy and unusual customization specific to the job? It's simple to update without breaking anything.

    This script doesn't have any WTFs I can perceive. Yes, there's some code copying, but that makes tweaking it to the task easier. Plus changes won't break anything.

    Where the WTF? I can't find it. Repetitive work isn't cluttered, and making uncommented code specific to what you're working on has the upside of not breaking the other /* 80 */ 83 places you put copies of it. Updates are easy and safe, you just have more to read.

    I don't have a problem with this content. So when if there's a bit of redundancy and unusual customizing unique to the task? It's easy to break without updatinging anything.

    This source code doesn't have any visible problems. OK, there's some copying and pasting and pasting but that makes working it to task easier. Plus updates won't crash anything.

    Where your boggle? I don't see it. see it. Repetitious code isn't cluttered and making nd has the upside of not breaking the other /* 80 */ 23 places you put copies of it. Updates are easy and safe, you

    Aha! I found your WTF!

  • EatenByAGrue (unregistered)

    Just a typical use of the for-case construct. You know, the one that looks like this: for (int i=0; i < 3; i++) { switch(i): case 0: puts("W"); break; case 1: puts("T"); break; case 2: puts("F"); }

  • mjk (unregistered)

    function popupRegulations(popWinURL, popWinTitle, popWinWidth, popWinHeight)

    function popupDemo(windowURL, windowTitle) ... function popupTutorials(popWinURL, popWinTitle, popWinWidth, popWinHeight)


    what is wrong with these functions? and phone num also doesn't ring a bell.

  • sdfggfdsg (unregistered) in reply to Anonymously Yours
    Anonymously Yours:
    I don't see an issue with this code. So what if there's a bit of redundancy and unusual customization specific to the task? It's easy to update without breaking anything.

    This code doesn't have any issues I can see. Okay, there's some function and procedure copying, but that makes tweaking it to the task easier. Plus updates won't break anything.

    Where the issue? I don't see it. Repetitious code isn't cluttered and making uncommented code specific to the task at hand has the upside of not breaking the other 80 places you put copies of it. Updates are easy and safe, you just have to read more.

    I don't see a WTF with this code. Who cares if there's a bit of redundancy and unusual customization specific to the job? It's simple to update without breaking anything.

    This script doesn't have any WTFs I can perceive. Yes, there's some code copying, but that makes tweaking it to the task easier. Plus changes won't break anything.

    Where the WTF? I can't find it. Repetitive work isn't cluttered, and making uncommented code specific to what you're working on has the upside of not breaking the other /* 80 */ 83 places you put copies of it. Updates are easy and safe, you just have more to read.

    I don't have a problem with this content. So when if there's a bit of redundancy and unusual customizing unique to the task? It's easy to break without updatinging anything.

    This source code doesn't have any visible probles. OK, there's some copying and pasting and pasting but that makes working it to task easier. Plus updates won't crash anything.

    Where your boggle? I don't see it. see it. Repetitious code isn't cluttered and making nd has the upside of not breaking the other /* 80 */ 23 places you put copies of it. Updates are easy and safe, you

    You need to be taken out back and shot.

  • Melvis (unregistered) in reply to sdfggfdsg
    sdfggfdsg:
    Anonymously Yours:
    I don't see an issue with this code. So what if there's a bit of redundancy and unusual customization specific to the task? It's easy to update without breaking anything.

    This code doesn't have any issues I can see. Okay, there's some function and procedure copying, but that makes tweaking it to the task easier. Plus updates won't break anything.

    Where the issue? I don't see it. Repetitious code isn't cluttered and making uncommented code specific to the task at hand has the upside of not breaking the other 80 places you put copies of it. Updates are easy and safe, you just have to read more.

    I don't see a WTF with this code. Who cares if there's a bit of redundancy and unusual customization specific to the job? It's simple to update without breaking anything.

    This script doesn't have any WTFs I can perceive. Yes, there's some code copying, but that makes tweaking it to the task easier. Plus changes won't break anything.

    Where the WTF? I can't find it. Repetitive work isn't cluttered, and making uncommented code specific to what you're working on has the upside of not breaking the other /* 80 */ 83 places you put copies of it. Updates are easy and safe, you just have more to read.

    I don't have a problem with this content. So when if there's a bit of redundancy and unusual customizing unique to the task? It's easy to break without updatinging anything.

    This source code doesn't have any visible probles. OK, there's some copying and pasting and pasting but that makes working it to task easier. Plus updates won't crash anything.

    Where your boggle? I don't see it. see it. Repetitious code isn't cluttered and making nd has the upside of not breaking the other /* 80 */ 23 places you put copies of it. Updates are easy and safe, you

    You need to be taken out back GIVEN and shot.

    Fixed.

  • Melvis (unregistered) in reply to Melvis
    Melvis:
    sdfggfdsg:
    Anonymously Yours:
    I don't see an issue with this code. So what if there's a bit of redundancy and unusual customization specific to the task? It's easy to update without breaking anything.

    This code doesn't have any issues I can see. Okay, there's some function and procedure copying, but that makes tweaking it to the task easier. Plus updates won't break anything.

    Where the issue? I don't see it. Repetitious code isn't cluttered and making uncommented code specific to the task at hand has the upside of not breaking the other 80 places you put copies of it. Updates are easy and safe, you just have to read more.

    I don't see a WTF with this code. Who cares if there's a bit of redundancy and unusual customization specific to the job? It's simple to update without breaking anything.

    This script doesn't have any WTFs I can perceive. Yes, there's some code copying, but that makes tweaking it to the task easier. Plus changes won't break anything.

    Where the WTF? I can't find it. Repetitive work isn't cluttered, and making uncommented code specific to what you're working on has the upside of not breaking the other /* 80 */ 83 places you put copies of it. Updates are easy and safe, you just have more to read.

    I don't have a problem with this content. So when if there's a bit of redundancy and unusual customizing unique to the task? It's easy to break without updatinging anything.

    This source code doesn't have any visible probles. OK, there's some copying and pasting and pasting but that makes working it to task easier. Plus updates won't crash anything.

    Where your boggle? I don't see it. see it. Repetitious code isn't cluttered and making nd has the upside of not breaking the other /* 80 */ 23 places you put copies of it. Updates are easy and safe, you

    You need to be taken out back and GIVEN A shot.

    Fixed.

    Fixed my own fix.

    CAPTCHA: praesent - got a praesent for my daed.

  • (cs)

    Actually I think "isDigit" and "isAlphaNumeric" are pretty good. IDK what all that other crap is though.

  • Anonymously Yours (unregistered)

    You all may be having trouble seeing the forest for all the trees. Due to the number of trees to all may be experiencing difficulty seeing the forest. The forest might escape your vision because of placement of trees. You guys may be having trouble noticing the forest for all the trees. Due to the quantity of foliage to all may be experiencing difficulty seeing the forest. The forest might escape your sight because of placement You all may not see the forest because of all the trees. As a result of the number of trees to all may be experiencing trouble seeing the forest. The forest not be in escape your vision because of placement of trees. of trees.

  • Zach Bora (unregistered)

    Aside from the top for loop, I don't see what is so bad about that code. That is unless there isn't also a server-side validation.

    Why do a server round trip when the values aren't going to work?

  • Anon-E-Moose (unregistered) in reply to mjk

    Notice anything about the parameters to those functions...?

  • Jeff G (unregistered) in reply to Anonymously Yours

    This. Rocks.

    trying not to laugh so hard - coworkers are looking at me puzzled

    Anonymously Yours:
    I don't see an issue with this code. So what if there's a bit of redundancy and unusual customization specific to the task? It's easy to update without breaking anything.

    This code doesn't have any issues I can see. Okay, there's some function and procedure copying, but that makes tweaking it to the task easier. Plus updates won't break anything.

    Where the issue? I don't see it. Repetitious code isn't cluttered and making uncommented code specific to the task at hand has the upside of not breaking the other 80 places you put copies of it. Updates are easy and safe, you just have to read more.

    I don't see a WTF with this code. Who cares if there's a bit of redundancy and unusual customization specific to the job? It's simple to update without breaking anything.

    This script doesn't have any WTFs I can perceive. Yes, there's some code copying, but that makes tweaking it to the task easier. Plus changes won't break anything.

    Where the WTF? I can't find it. Repetitive work isn't cluttered, and making uncommented code specific to what you're working on has the upside of not breaking the other /* 80 */ 83 places you put copies of it. Updates are easy and safe, you just have more to read.

    I don't have a problem with this content. So when if there's a bit of redundancy and unusual customizing unique to the task? It's easy to break without updatinging anything.

    This source code doesn't have any visible probles. OK, there's some copying and pasting and pasting but that makes working it to task easier. Plus updates won't crash anything.

    Where your boggle? I don't see it. see it. Repetitious code isn't cluttered and making nd has the upside of not breaking the other /* 80 */ 23 places you put copies of it. Updates are easy and safe, you

  • Stephen E. Baker (unregistered)
    <quote> Just a typical use of the for-case construct. You know, the one that looks like this: for (int i=0; i < 3; i++) { switch(i): case 0: puts("W"); break; case 1: puts("T"); break; case 2: puts("F"); } </quote>

    WTFTFF

  • Aslan (unregistered) in reply to Anyone
    Anyone:
    teh jav:
    Newb:
    Mandatory summarization: Got paid to port bad code, found bad code.
    Like Mandatory Fun Day but less funny.

    So like Mandatory Fun Day then :P ?

    Mandatory Fun Day was a little before it's time and misdirected. No, wait! Seriously! Hear me out!

    At The Daily WTF, the point is for the readership to understand and belittle the content. It reaffirms our pretentious "Of course I'm the best programmer ever" mindset and makes us feel good. Even the 2nd string programmers can say, "Hey, at least I'm not as bad as that guy!"

    To put a comic like Mandatory Fun Day in that atmosphere, a comic that wants to take itself seriously, and that the author wants the audience to take seriously .. is like throwing sheep into a lion's den. Of course it's going to be ripped to shreds ... what do you expect? That's what we do here! (That's why we visit the site!)

    This is where Mandatory Fun Day went wrong. If the author(s) could have gotten over the need for it to be a good comic, and instead treated it like a WTF ... some of those recaptions in the forums and comics that lampooned the original comic were HILARIOUS.

    In fact, I was just telling my brother (non-programmer) about one of the lampoon comics last night. It ended with our contractor hero crying and saying, "The Aristocrats" ... which is just classic.

    Anyway, I think MFD could be brought back, so long as the author(s) and Alex realized they were throwing a visual sheep instead of code sheep to us hungry lions.

  • (cs) in reply to Newb
    Newb:
    Mandatory summarization: Got paid to port bad code, found bad code.

    That is kind of the whole point of this website, yes. Were you looking for thedailypeoplewhoarecompetentattheirjobsandeverythingturnsoutfine.com instead?

  • Mogri (unregistered)

    Reaction reel:

    "function popupRegulations(popWinURL, popWinTitle, popWinWidth, popWinHeight)"

    I don't see what's wrong with this.

    "function popupDemo(popWinURL, popWinTitle)"

    Okay, wait.

    "function popupWindow(popWinURL, popWinTitle, popWinWidth, popWinHeight)"

    WTF?

  • sad bob (unregistered) in reply to Anonymously Yours
    Anonymously Yours:
    You all may be having trouble seeing the forest for all the trees. Due to the number of trees to all may be experiencing difficulty seeing the forest. The forest might escape your vision because of placement of trees. You guys may be having trouble noticing the forest for all the trees. Due to the quantity of foliage to all may be experiencing difficulty seeing the forest. The forest might escape your sight because of placement You all may not see the forest because of all the trees. As a result of the number of trees to all may be experiencing trouble seeing the forest. The forest not be in escape your vision because of placement of trees. of trees.

    it was clever the first time. not that time.

  • Kagome Higurashi (unregistered) in reply to mjk

    Looks like someone had the "clever" idea of defining all the conditions and error messages in arrays, and looping through the form to test each one. Then realized only one field needed it, but did it anyway. Then did it horribly wrong.

    mjk:
    function popupRegulations(popWinURL, popWinTitle, popWinWidth, popWinHeight)

    function popupDemo(windowURL, windowTitle) ... function popupTutorials(popWinURL, popWinTitle, popWinWidth, popWinHeight)


    what is wrong with these functions?

    Redundancy.
    Stephen E. Baker:
    <quote> Just a typical use of the for-case construct. You know, the one that looks like this: for (int i=0; i < 3; i++) { switch(i): case 0: puts("W"); break; case 1: puts("T"); break; case 2: puts("F"); } </quote>

    WTFTFF

    Double fail!

  • Anonymously Yours (unregistered) in reply to sad bob
    sad bob:
    Anonymously Yours:
    You all may be having trouble seeing the forest for all the trees. Due to the number of trees to all may be experiencing difficulty seeing the forest. The forest might escape your vision because of placement of trees. You guys may be having trouble noticing the forest for all the trees. Due to the quantity of foliage to all may be experiencing difficulty seeing the forest. The forest might escape your sight because of placement You all may not see the forest because of all the trees. As a result of the number of trees to all may be experiencing trouble seeing the forest. The forest not be in escape your vision because of placement of trees. of trees.

    it was clever the first time. not that time.

    I was just replying to the people who seemed to miss it the first time. I'd rather make what happened more obvious instead of explaining the other post. That takes all the fun out of it.

  • Darren (unregistered) in reply to gasman
    gasman:
    Newb:
    Mandatory summarization: Got paid to port bad code, found bad code.

    That is kind of the whole point of this website, yes. Were you looking for thedailypeoplewhoarecompetentattheirjobsandeverythingturnsoutfine.com instead?

    Wouldn't that site be hard to find content for?

  • CFMExpert (unregistered)

    Wow.

    1. RegEx anyone?
    2. isNaN() anyone?
    3. Server side validation anyone?
    4. Anyone hunt down and systematically destroy/kill/immobilize that "I don't see the problem here" guy yet?
  • MRAB (unregistered) in reply to Mike Caron
    Mike Caron:
    If you learned anything about for loops by looking at that code, you're doing it wrong.

    Captcha: quis (yes, I am feeling a bit quisy)

    <smug_mode> FYI, "quis" is Latin for "who", "what" or "which", as in "Who, what or which one of you wrote this?". </smug_mode>

  • awasson (unregistered)

    Yes. I could see the problem with that loop from a mile away... It should be a switch statement instead of that clunky if/or conditional ;p

    I've copied those numeric and alphanumeric functions to my library. They'll come in handy. LMFAO

  • (cs)
    SR:
    Beldar the Phantom Replier:
    function isDigit(digit) { var charOk = "0123456789"; return !(charOk.indexOf(digit) == -1) }

    function isAlphaNumeric(digit) { var charOk = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; return !(charOk.indexOf(digit) == -1) }

    What is so bad about these two functions? Are they really WTF worthy?

    I could understand if either of the soft-coded strings were missing some digits or letters (respectively), but I must just be missing the WTF moment here.

    JS has isNaN() and !isNaN() to do these things.

    !isNaN would be fine instead of isDigit, unless you want you only want to allow digits, which would be how I would expect isDigit to be used (e.g. for a 5 character zip code where "12345" should pass validation and "-1.23" should not).

    And I don't have any idea how you could use either of those functions to validate if a character is alphanumeric or not, so that would still leave isAlphaNumeric out in the cold.

    Of course just matching [0-9]+ and [0-9A-Za-z]+ would work, but then you would be assuming that the next programmer to touch your code would be able to use regular expressions correctly - an assumption this site should have put out of your thoughts long ago.

    Anybody else want to help me out?

  • conventio (unregistered) in reply to Anonymous
    Alex Papadipamopaopeaopolis:
    "On the bright side," Clark added, "at least I finally found something impressively bad."
    Sorry, Clark, you really didn't. This is the pitiful status quo in the world of Javascript. I blame the "real" programmers who consider "the UI" out of the realm of logic, reason, and solid architecture.

    inb4 TRWTF=Javascript

  • sad bob (unregistered) in reply to Anonymously Yours
    Anonymously Yours:
    sad bob:
    Anonymously Yours:
    You all may be having trouble seeing the forest for all the trees. Due to the number of trees to all may be experiencing difficulty seeing the forest. The forest might escape your vision because of placement of trees. You guys may be having trouble noticing the forest for all the trees. Due to the quantity of foliage to all may be experiencing difficulty seeing the forest. The forest might escape your sight because of placement You all may not see the forest because of all the trees. As a result of the number of trees to all may be experiencing trouble seeing the forest. The forest not be in escape your vision because of placement of trees. of trees.

    it was clever the first time. not that time.

    I was just replying to the people who seemed to miss it the first time. I'd rather make what happened more obvious instead of explaining the other post. That takes all the fun out of it.

    fair shout guv

  • Paul (unregistered) in reply to Kagome Higurashi
    Kagome Higurashi:
    mjk:
    what is wrong with these functions?
    Redundancy.

    But they're not totally redundant.

    If you want to change the way that 'Tutorials' popup now, then you just change one function - job done. If you just had one function instead, it would be a lot harder, as you'd have to find everywhere that called 'CreateGenericPopup' which used it in a 'Tutorial' sense.

  • iMalc (unregistered) in reply to Anonymously Yours
    Anonymously Yours:
    I don't see an issue with this code. So what if there's a bit of redundancy and unusual customization specific to the task? It's easy to update without breaking anything.

    This code doesn't have any issues I can see. Okay, there's some function and procedure copying, but that makes tweaking it to the task easier. Plus updates won't break anything.

    Where the issue? I don't see it. Repetitious code isn't cluttered and making uncommented code specific to the task at hand has the upside of not breaking the other 80 places you put copies of it. Updates are easy and safe, you just have to read more.

    I don't see a WTF with this code. Who cares if there's a bit of redundancy and unusual customization specific to the job? It's simple to update without breaking anything.

    This script doesn't have any WTFs I can perceive. Yes, there's some code copying, but that makes tweaking it to the task easier. Plus changes won't break anything.

    Where the WTF? I can't find it. Repetitive work isn't cluttered, and making uncommented code specific to what you're working on has the upside of not breaking the other /* 80 */ 83 places you put copies of it. Updates are easy and safe, you just have more to read.

    I don't have a problem with this content. So when if there's a bit of redundancy and unusual customizing unique to the task? It's easy to break without updatinging anything.

    This source code doesn't have any visible probles. OK, there's some copying and pasting and pasting but that makes working it to task easier. Plus updates won't crash anything.

    Where your boggle? I don't see it. see it. Repetitious code isn't cluttered and making nd has the upside of not breaking the other /* 80 */ 23 places you put copies of it. Updates are easy and safe, you

    I think we've found the code's author! Who else would defend it so much! "Idle Hands Are The Devil's Tools"? Erm fixed it... "Copy and Paste Are The Devil's Tools"

  • Garmoran (unregistered)

    TRWTF is that this is the first code WTF where I didn't have to think or look for an explanation of the WTF

    Captcha: quibus - transport to a qui resort?

  • (cs) in reply to Paul
    Paul:
    Kagome Higurashi:
    mjk:
    what is wrong with these functions?
    Redundancy.

    But they're not totally redundant.

    If you want to change the way that 'Tutorials' popup now, then you just change one function - job done. If you just had one function instead, it would be a lot harder, as you'd have to find everywhere that called 'CreateGenericPopup' which used it in a 'Tutorial' sense.

    Then why not define a popup function with most common features, called Popup and use it for TutorialPopup, HelpPopup, SomethingPopup etc? For one thing, this is copypasta, and if someone decides that the popups should be resizeable, you have to change it in ALL functions. Secondly, instead of having uniform popups with same width etc. that you'd just have to call throughout the code with important information (title and contents) only, you need to call it everywhere with width and height. That's redundant enough to be worthless.

  • DropDeadThread (unregistered)

    I think that this level of redundancy is brillant. Saves the trouble of maintaining a repository. If one function is accidentally deleted just copy the code into a new one!

  • (cs) in reply to Paul
    Paul:
    Kagome Higurashi:
    mjk:
    what is wrong with these functions?
    Redundancy.

    But they're not totally redundant.

    If you want to change the way that 'Tutorials' popup now, then you just change one function - job done. If you just had one function instead, it would be a lot harder, as you'd have to find everywhere that called 'CreateGenericPopup' which used it in a 'Tutorial' sense.

    I think I forgot to mention something important about this file when I submitted it: you are looking at a disturbingly small fraction of it. The file was just shy of 1,900 lines and weighs in at just under 50kb.

    Each of these popup functions is only called once, and never on the same page. Most validation functions we called by middleman functions that were called by helper functions bound to the actual events (that's three calls deep, for those of you keeping score at home). By the time I trimmed and abstracted the file completely was down to about 250 lines and still powered the whole site.

    Thankfully, shortly after I submitted this story they suspended the contract with these people and moved me to something else. If I didn't think it'd break the Anonymity rules I would post a link to where they still have the original version in production, for all to see.

  • isDigit (unregistered)

    Maybe it is just me but "function isDigit(digit)" may be ok depending on the validation required. So for those suggesting isNaN() and !isNaN() try calling isNaN("0xff") and see what result you get.

  • Anonymously Yourses (unregistered) in reply to Anonymously Yours
    Anonymously Yours:
    I don't see an issue with this code. So what if there's a bit of redundancy and unusual customization specific to the task? It's easy to update without breaking anything.

    This code doesn't have any issues I can see. Okay, there's some function and procedure copying, but that makes tweaking it to the task easier. Plus updates won't break anything.

    Where the issue? I don't see it. Repetitious code isn't cluttered and making uncommented code specific to the task at hand has the upside of not breaking the other 80 places you put copies of it. Updates are easy and safe, you just have to read more.

    I don't see a WTF with this code. Who cares if there's a bit of redundancy and unusual customization specific to the job? It's simple to update without breaking anything.

    This script doesn't have any WTFs I can perceive. Yes, there's some code copying, but that makes tweaking it to the task easier. Plus changes won't break anything.

    Where the WTF? I can't find it. Repetitive work isn't cluttered, and making uncommented code specific to what you're working on has the upside of not breaking the other /* 80 */ 83 places you put copies of it. Updates are easy and safe, you just have more to read.

    I don't have a problem with this content. So when if there's a bit of redundancy and unusual customizing unique to the task? It's easy to break without updatinging anything.

    This source code doesn't have any visible probles. OK, there's some copying and pasting and pasting but that makes working it to task easier. Plus updates won't crash anything.

    Where your boggle? I don't see it. see it. Repetitious code isn't cluttered and making nd has the upside of not breaking the other /* 80 */ 23 places you put copies of it. Updates are easy and safe, you

  • (cs)

    This looks like the kind of JavaScript that I wrote when I was new to it. In my experience, it takes a while to begin to understand the language and browser built-ins. It's WTF worthy, but I think the author can be forgiven. I still write crappy JavaScript, but I'd like to think /some/ of it is better than this. ;)

  • pizzaguy (unregistered) in reply to xtremezone
    xtremezone:
    This looks like the kind of JavaScript that I wrote when I was new to it. In my experience, it takes a while to begin to understand the language and browser built-ins. It's WTF worthy, but I think the author can be forgiven. I still write crappy JavaScript, but I'd like to think /some/ of it is better than this. ;)

    That first for loop is unforgivable. It's not like JS does control flow that differently.

  • TimTom (unregistered)

    I agree today coding standards are totally different, and are probably much more efficient, but the coder obviously have not learn them by the time he wrote these lines.

    I am forced to agree with the previous comment. I have seen much much worse.(Apart from the 1st sample which is really really ugly). It is probably coming from a guy who is unexperienced and the path he takes is uncommon these days. Or from a very experienced guy who has always done things this way.

    1 He was smart enough to factor the logic in function. And believe me, that s allready being a top tier programmer. Lots of our collegues prefer copy paste. You think WTF or funny ? Not when you have to work with them.

    2 His code is readable and easy to modify. Moreover it somehow follows a pattern : writing simple code the 1st rule in being polite to the one who will have to read it ( and believe me lots of our collegues are not aware that some day some one will have to grok their code, and don t even think it might be them)

    3 He solved the problem he had to solve. And it seems like he did it on his own.

    Is it really your job to hunt for obsolete patterns in code that is 10 years old ? Please accept my apologies if it s not. I d rather look for areas that can be improved in borked code. If it s not broken don t fix it.

Leave a comment on “Loopy Validation”

Log In or post as a guest

Replying to comment #:

« Return to Article