• (nodebb)
           case "processCompletedCompetition":
               handleCompetitionFormReturn()
               //handleProcessCompletedCompetition();
           break;
    

    This one is somewhat concerning. I'll leave it as an exercise for the reader to determine why.

           case "submitLogout-noReload":
               // do nought, this is handled earlier
               // in AjaxEngine::makeRequest
           break;
    

    Whoever wrote this is unaware of the difference between "nought" (zero) and "naught" (nothing). And if it's handled earlier, why are we even here?

    Addendum 2022-02-28 06:47: It might be indifference rather than a lack of awareness, but that's actually worse.

  • Ullli (unregistered)

    My browser is broken. I searched for the keyword default and there were no matches. Not in the article and not in the code. At least this statement inside the giant switch construct would make the un-maintainable if construct superfluous.

  • (nodebb) in reply to Steve_The_Cynic

    According to the built in dictionary on my laptop "nought" as a synonym for "nothing" is accepted usage.

    As an alumnus of the University of York, I would say "do nowt" is correct.

    Addendum 2022-02-28 07:29: I should have said nought is a synonym for nothing in American English, not British English.

  • (nodebb)
    fantasy-football... handles microtransactions and in-game items passed between players

    TRWTF

  • (nodebb) in reply to Ullli

    At least [default] inside the giant switch construct would make the un-maintainable if construct superfluous.

    I think, in Javascript, if the default statement has no code associated e.g.

    default: break;
    

    then it is itself superfluous. You might still put it in, but only for documentation purposes. Thus the if construct is already superfluous unless it has an else (not shown) to handle any other cases.

    Addendum 2022-02-28 07:39: Turns out I'm wrong about the if being superfluous (see below).

  • (nodebb)

    FTA

    As you might gather here, this repeats all the same validation

    No it doesn't. The if condition tests for 33 different strings. The switch statement has... well, I gave up counting at 48 cases. The if filters out several strings that are perfectly fine as far as the switch is concerned.

  • (nodebb)

    Neither the if now the switch check for "FILE_NOT_FOUND"

  • eric bloedow (unregistered)

    this reminds me of something i read in an old gaming magazine: someone working on a Baseball game made a typo in a complex formula, a "-" instead of "+"...and this single wrong character made the ENTIRE "curveball" subroutine work BACKWARDS! that is, if you tried to make the ball curve left, it would curve right instead! an interesting example of how easy it is for program "bugs" to occur.

  • Loren Pechtel (unregistered)

    I didn't too much mind the previous monster switch, but this atrocious. ONE copy of your magic strings! I don't really care if they are constants or in the switch, I very much care if they occur more than once.

  • (nodebb)

    I may be weird in that, but my main complaint is that the

    break
    

    is on the same level of indentation as the

    case
    
  • (nodebb) in reply to Jeremy Pereira

    BrE here: "naught" => nothing, 'i care naught for that' "nought" => zero, 'dial one-nought-one for help'

  • MaxiTB (unregistered) in reply to R3D3

    That is the PASCAL style of scoping, just imagine it as begin end :-)

  • Plant (unregistered)

    I think we all know the real point of minification is to hide embarrassing code.

  • (nodebb) in reply to Jeremy Pereira

    Yeah, well, I'm British, so they very much are different.

  • löchleindeluxe (unregistered)

    This is JavaScript, so CONSTANT_WITH_TYOP would just autoinitialize to "undefined", right? Yeah, ok, that's slightly better. (They probably have proper enum types now, though? I kinda stopped paying attention around the time .querySelectorAll() became a thing.)

  • Human Parser (unregistered) in reply to Loren Pechtel

    I truly hate people like you. I'm not a parser, compilers deduplication, or compressor. Deduplicating strings is the job of the computer, not me.

    Moving every string to a variable removes context, information, increases complexity - all things that you don't want. For the claim "but you can't mis-type it though" - yes you can. This is an interpreted language. You can't know if it works until you run the code and test it - the whole thing you're trying to avoid doing by complexifying the code with unhelpful variables.

    I've worked with people like you before, and it's awful.

  • Airdrik (unregistered) in reply to löchleindeluxe

    no, javascript (still) doesn't have proper enums (typescript does - they compile down to an object with the enum values as object fields, which is the next closest recommended thing in javascript).
    I think you're right about the uninitialized variable; though that should be something that your editor's syntax highlighter or the linter should point out for you.

    Wrt the 'discussion' about naught vs. nought: sure they may have different meanings when looking at their precise definitions; however in context (with 'use strict off') it really doesn't change the what the comment is telling you (unless you really want to get picky about doing 'zero' involving doing something more than just nothing which we can see that the code in question is actually doing). Really it's all just a pointless nit-pick on a pointless comment optimization (saving one character and a whole syllable vs. just using 'nothing').

  • Officer Johnny Holzkopf (unregistered) in reply to eric bloedow
    Comment held for moderation.

Leave a comment on “Switch Kicker”

Log In or post as a guest

Replying to comment #:

« Return to Article