phetsims / arithmetic

"Arithmetic" is an educational simulation in HTML5, by PhET Interactive Simulations.
http://phet.colorado.edu/en/simulation/arithmetic
GNU General Public License v3.0
5 stars 5 forks source link

clean up code to make it more maintainable #150

Closed jbphet closed 8 years ago

jbphet commented 8 years ago

This sim is getting close to publication, and the code could use some improvement to variable names, comments, and in some cases code structure in order to make it more maintainable. This was discussed in a recent status meeting, and we decided to do as much of this as possible with a few hours of effort.

jbphet commented 8 years ago

One thing that had always bothered me about the structure of this code was that there was a data structure in the main model class ArithmeticModel called answerSheet that tracked which cells were used (which maps to which arithmetic problems had been solved). This structure was repopulated from the active level each time the user switched to a different level. I couldn't figure out why it was done this way. Why isn't there a model element for each cell that tracks whether that cell has been used? And, if not that, why not encapsulate the information about which cells were used in the model of the level? Since I never identified a good answer to these questions, I went ahead and did a fairly major refactor where the information about which cells are used is now kept solely in the level model type, i.e. LevelModel. Hopefully this will make the code easier to understand for any future maintainers.

jbphet commented 8 years ago

@ariel-phet and I decided to do as much of this as time permits, and time is up. Closing.