Javascript classes, but more a design question

I’m of same opinion as @Chrisir’s.

That is, have a Point class plus a Grid class to manage the instances of Point.

I did the same for this sketch “Self Avoiding Walk II”:

In its subfolder “modules/” there are 3 JS files (plus 3 CoffeeScript files :coffee: ):

  1. https://Self-Avoiding-Walk-II-CoffeeScript.Glitch.me/modules/grid.js
  2. https://Self-Avoiding-Walk-II-CoffeeScript.Glitch.me/modules/spot.js
  3. https://Self-Avoiding-Walk-II-CoffeeScript.Glitch.me/modules/step.js

In file “grid.js” I have a class Grid that inside its method createGrid() 2 arrays are created:

  1. a 2d array grid[][] of Spot objects.
  2. and a 1d array path[] of also Spot objects.

Basically the singleton Grid class manages all instances of the Spot class.

And in turn, each Spot instance has 4 instances of class Step inside its 1d array options[].

Plus a temporary 1d array dirs[] which collects each Step that hasn’t been tried.

In short, I think that kind of hierarchy of classes is pretty organized and works very well. :factory_worker: