- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
This one is somewhat concerning. I'll leave it as an exercise for the reader to determine why.
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.
Admin
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-maintainableif
construct superfluous.Admin
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.
Admin
TRWTF
Admin
I think, in Javascript, if the default statement has no code associated e.g.
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 anelse
(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).Admin
FTA
No it doesn't. The
if
condition tests for 33 different strings. Theswitch
statement has... well, I gave up counting at 48 cases. Theif
filters out several strings that are perfectly fine as far as theswitch
is concerned.Admin
Neither the if now the switch check for "FILE_NOT_FOUND"
Admin
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.
Admin
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.
Admin
I may be weird in that, but my main complaint is that the
is on the same level of indentation as the
Admin
BrE here: "naught" => nothing, 'i care naught for that' "nought" => zero, 'dial one-nought-one for help'
Admin
That is the PASCAL style of scoping, just imagine it as begin end :-)
Admin
I think we all know the real point of minification is to hide embarrassing code.
Admin
Yeah, well, I'm British, so they very much are different.
Admin
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.)
Admin
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.
Admin
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').