phetsims / rutherford-scattering

"Rutherford Scattering" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
2 stars 3 forks source link

RSBaseModel uses field defined in its subclasses #160

Closed pixelzoom closed 5 years ago

pixelzoom commented 5 years ago

Noted while investigating #158.

RSBaseModel uses userInteractionProperty, which is not undefined in RSBaseModel. It's defined in subclasses RutherfordAtomModel and PlumPuddingModel. Reaching down in the class hierarchy is a definite no no.

jessegreenberg commented 5 years ago

Thanks, a big no-no. Also, this is duplicated in the two subtypes and should be moved to RSBaseModel.

    var userInteractionListener = function( userInteraction ) {
      if ( userInteraction ) {
        self.removeAllParticles();
      }
    };
jessegreenberg commented 5 years ago

userInteractionProperty is now a param for RSBaseModel, created and passed in from each subtype. @pixelzoom would you mind reviewing?

pixelzoom commented 5 years ago

👍 closing.