Skip to main content
12 events
when toggle format what by license comment
Apr 16, 2017 at 9:11 history tweeted twitter.com/StackSoftEng/status/853536381099966464
Apr 15, 2017 at 14:14 vote accept AFP_555
Apr 15, 2017 at 14:10 comment added AFP_555 @BenCottrell Yes! This wouldn't have happened to me if I was using Java or Python. Classes allow to encapsulate in instances what in Javascript would be all over the global environment. First time using Javascript, it is a good thing I learned this now.
Apr 15, 2017 at 12:36 answer added gnasher729 timeline score: 3
Apr 15, 2017 at 8:26 answer added Ewan timeline score: 11
Apr 15, 2017 at 0:31 comment added Ben Cottrell Consider treating the structure of your JavaScript code as you would in other languages (such as those which use "real" classes). Some useful links on this related question on SO: stackoverflow.com/questions/927651/…
Apr 14, 2017 at 22:26 comment added AFP_555 @KilianFoth Thanks. Could you please elaborate with some code so I can check the answer?
Apr 14, 2017 at 22:20 comment added Kilian Foth A common remedy when you find yourself passing arguments many layers deep is to create a method object: an object of a new class whose methods correspond to the functions that pass the parameters along. The parameters can then become variables local to the object, and its methods need not pass along the values anymore.
Apr 14, 2017 at 21:32 comment added AFP_555 Avoid it like the plague. Understood. Could you elaborate a little more on "you haven't broken the problem up correctly". I understand the general idea but I can't come up with an example or something to reeeally understand it.
Apr 14, 2017 at 21:26 history edited AFP_555 CC BY-SA 3.0
added 184 characters in body
Apr 14, 2017 at 21:25 comment added mgw854 Typically, if you're passing variables very deeply, you haven't broken the problem up correctly. As for global variables driving state elsewhere in the system, avoid it like the plague. It's impossible to manage at a certain point, and you will find things breaking randomly because some state is mutated by a function that you weren't expecting randomly.
Apr 14, 2017 at 21:22 history asked AFP_555 CC BY-SA 3.0