Re:Applying NASA coding standards to JavaScript
by lscharen on Thursday January 08, 2015 @09:34AM
(#8856492)
Totally agree on this point.
My feeling is that Rule 9 roughly maps to following the Law of Demeter in that you shouldn't chase properties down more than one level, e.g.
Good:
var something = obj.property;
Bad: var something = obj.property1.property2.property3;
Re:Applying NASA coding standards to JavaScript
by adestefan on Thursday January 08, 2015 @10:51AM
(#8856884)
Once again this has more to do with the idea that everything must be deterministic. Using a pointer when it's not absolutely needed is just one more place where a non-deterministic runtime issue can crop up.
Re:Applying NASA coding standards to JavaScript
by PixelsCommander on Thursday January 08, 2015 @09:49AM
(#8856571)
This is the missing thing, will add. Thanks guys!
Re:Applying NASA coding standards to JavaScript
by siscia on Thursday January 08, 2015 @09:41AM
(#8856522)
I agree that if we apply rule 9 to JS we would end up with something extremely different.
However don't use first-class functions in my opinion it would means to not pass function around, in anything.
So no callback and no a lot of nice "trick" that JS use (and I really enjoy.)
I don't think that JS can live with rule 9.
Re:Applying NASA coding standards to JavaScript
by PixelsCommander on Thursday January 08, 2015 @10:05AM
(#8856645)
Yep, applying this restriction on functions is something I would avoid to suggest as they are a cornerstone of modern JS development.
However another part of rule seems to be something to consider.
Re:Applying NASA coding standards to JavaScript
by debacle on Thursday January 08, 2015 @10:19AM
(#8856719)
There's a reason, though, that people call it "callback hell." Many people are irresponsible with first-class functions.
Re:Applying NASA coding standards to JavaScript
by marrs on Thursday January 08, 2015 @09:56AM
(#8856597)
Perhaps I'm misunderstanding you, but it sounds like you're saying that you'll reduce complexity by avoiding jquery, underscore, and half of the built in API. This is the opposite of my experience.
Re:Applying NASA coding standards to JavaScript
by debacle on Thursday January 08, 2015 @10:18AM
(#8856710)
Cyclomatic complexity is different from execution complexity.
Re:Applying NASA coding standards to JavaScript
by marrs on Thursday January 08, 2015 @10:50AM
(#8856879)
Implying that execution complexity is increased? Is a function not dynaically bound at the last moment anyway, regardless of how it is called? Where is the increased complexity?
Re:Applying NASA coding standards to JavaScript
by debacle on Thursday January 08, 2015 @10:56AM
(#8856917)
Yes. Every time you introduce a new library, the deterministic nature of a system is challenged. It's kind of a silly point, though - the browser itself introduces more execution complexity than any JavaScript library could.
Re:Applying NASA coding standards to JavaScript
by marrs on Thursday January 08, 2015 @11:42AM
(#8857177)
Oh, I see what you mean now. I was referring to those libraries as an example of a useful application of the pattern. My point was, if you disallow passing functions, you disallow those patterns.
I disagree that JS developers can't get anything out of this. The rule clearly states that first-class functions (function pointers in C) should not be used. Whether that's a good or bad idea to follow is another matter, but the author's interpretation that it doesn't apply to JS is wrong. IMO, it's likely to reduce complexity and bugs quite a bit so it seems like the rule should be generally followed if one follows the rest of the rules, despite giving up such a powerful and flexible feature.