6 ms·
I find it most disturbing that they are polluting the global namespace with all those variables and functions. Don't JavaScript developers these days understand
by Osiris 14y ago
I find it most disturbing that they are polluting the global namespace with all those variables and functions. Don't JavaScript developers these days understand how to properly scope their JavaScript?
- adrianparsons 14y agoI like that bad namespacing is what you find disturbing here.
- hrabago 14y agoI can't help it. It's just the way I'm wired.
- shaggyfrog 14y agoAre you really asking why a developer tasked with creating something intentionally deceptive didn't use best practices? I'm thinking not a lot of care or attention to anything was paid that day.
- zerostar07 14y agoProbably wanted to make it more readable, it's not even minified.
- artursapek 14y agoI don't think a JSLint-compliant, file-minifying developer would need to resort to this kind of work.
- zerostar07 14y agoI 'm implying s?he did it on purpose to shame his/her bosses.
- artursapek 14y agoAh, perhaps this is the case. Would have been fun to stumble across a "Help, I'm trapped in a bullshit factory!" comment or something. But that would not help one's career.
- UnFleshedOne 14y agoDifferent kind of ethics: "It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter." (lost the source of the quote)
- MBlume 14y agohttp://en.wikiquote.org/wiki/Nathaniel_Borenstein http://en.wikiquote.org/wiki/Nathaniel_Borenstein To understand how these problems can be addressed, it is instructive to consider an analogy. Imagine, for a moment, that somewhere in the basement of the Pentagon there are two computers. They are identical hardware, and they run identical software; they are as alike as two peas in a pod. On each of them, there is an executable procedure called "DestroyBaghdad". On one of the machines, executing this procedure does nothing. On the other, the effects of executing the procedure are disastrous, at least for the citizens of Iraq. The only difference between the two machines is a single wire coming out of the back of the second machine.[1] The point, of course, is that nothing inherent to a computational language is dangerous; danger is posed only insofar as the effects of executing statements in a language include "side-effects" in the external world. If all the "wires" connecting a computational language to the outside world are cut, then executing programs in that language is harmless. (An exception to this claim is that such a program can still tie up the CPU, virtual memory, or swap space on a machine by going into an infinite loop; this can be handled via resource limitations.) [1]It should be noted that no ethically-trained software engineer would ever consent to write a "DestroyBaghdad" procedure. Basic professional ethics would instead require him to write a "DestroyCity" procedure, to which "Baghdad" could be given as a parameter. http://www.guppylake.com/~nsb/CSCW-ATOMICMAIL.txt http://www.guppylake.com/~nsb/CSCW-ATOMICMAIL.txt
- ryanac 14y agoHad me laughing so I tried to find it: http://en.wikiquote.org/wiki/Nathaniel_Borenstein http://en.wikiquote.org/wiki/Nathaniel_Borenstein
- deleted 14y ago[deleted]
- luigi 14y agoI find the 8 space indentation most disturbing.
- hrabago 14y agoIt's the Tab character.
- luigi 14y agoAh, so it is. Then I'm disturbed that browsers render a tab as 8 spaces.
- Zirro 14y agohttps://developer.mozilla.org/en/CSS/tab-size https://developer.mozilla.org/en/CSS/tab-size was just implemented in the newest browsers, for all your tab-sizing needs :)
- cpeterso 14y agoPatches accepted!
- hrabago 14y ago8 is the traditional size of tabs though, isn't it? Seems like a reasonable default. That's partially why some teams (mine included) discourages the use of tabs in source code - its appearance varies depending on what's rendering it, affecting code readability.
- Deestan 14y agoAs long as it's "single page bound" JS like this, I honestly don't think it matters one bit. Reusable components and utility libraries is something different, of course.
- sjs 14y agoIt's still incredibly error prone and just bad practice. It's a telltale sign of a bad developer because a good dev would instinctively just use var without thinking about it. Good devs may make a mistake here or there but this is clearly well beyond a forgotten var keyword.
- slantyyz 14y ago>> It's a telltale sign of a bad developer I'm just guessing, but the site was probably not developed by a technical team, probably some web shop that specializes more on the design/layout/content side and not on the JS side. So it's likely it's the work of a non-developer than a bad developer. The net result is the same (bad code) but the distinction is that the code was possibly written by someone who wouldn't even be considered a developer.
- aaronasterling 14y agoBut when writing code, how do you know that it's always going to be "single page bound"? YAGNI is frequently useful poison and nothing more. When it's so easy to do it right the first time, why not?
- Deestan 14y ago> When it's so easy to do it right the first time, why not? a) Because it isn't "right" as such. It's just "better" if the code is going to be reused. Which it isn't. b) The code style serves as documentation. I can clearly read from this code that it's not a reusable component. It is now easier for me to get an idea of how and where this code is being used in the site. c) Personally, I'm wary of "pre-emptive generalization". Every layer of abstraction makes the code slightly less readable. Also, unless there exists at least two use cases right now, you're not likely to get the reusability right anyway.
- wavephorm 14y agoThe web developers they hired were liberal.
- stevewilhelm 14y agoWas just looking at namespace best practices today for a utility library I was implementing. Is there a defacto standard?
- aaronasterling 14y agoThe defacto standard is to put nothing in an enclosing namespace unless it's needed there. The purpose of functions (especially in a language like JS) is to wrap up everything that's needed to accomplish a given task and leave no mess behind.
- entropy_ 14y agoThen why oh why are variables global by default? (this is not meant as an attack on your point, I fully agree, I just find this awfully frustrating about JS. Sane languages have scoped by default and a global keyword, not the other way around)
- aaronasterling 14y agoYou'd have to ask its designer. Sloppy programmers do like globals and JS was targeted for them.