phetsims / isotopes-and-atomic-mass

"Isotopes And Atomic Mass" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
3 stars 3 forks source link

Saving of state in 2nd screen is inefficient and overly complicated #103

Open jbphet opened 3 years ago

jbphet commented 3 years ago

While working on #101, I found that that process of saving and restoring the state for the various atom configurations on the 2nd screen has some big problems. I unfortunately missed this when doing the code review on this portion of the sim. The problem is that when state has been stored for a given element and is later restored, the code in MixIsotopesModel.setState() first creates the buckets and adds an initial set of particles to them, and then removes all of the particles and buckets and restores the saved state using MixIsotopesModel.setState().

In its current form, the code functions correctly, but it is inefficient and confusing because it creates a bunch of things only to destroy them immediately and create other things instead. Also, I imagine that this would be quite problematic for phet-io when this sim is instrumented.

jbphet commented 3 years ago

I tried a couple of quick fixes but didn't have much luck, so I think this will take a little time to hammer out. I'm going to leave it unassigned and it will act as a note to anyone who comes here to implement phet-io, essentially saying, "You'd better take care of this first.".