phetsims / plinko-probability

"Plinko Probability" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
5 stars 7 forks source link

bad method of overriding histogramModeProperty default value #69

Closed pixelzoom closed 7 years ago

pixelzoom commented 7 years ago

The default value for histogramModeProperty is 'cylinder', see base type PlinkoProbabilityCommonView.

But Lab screen needs a different default value ('counter) for this Property. Here's how it currently solves this problem. In the constructor, it does this:

this.viewProperties.histogramModeProperty.set( 'counter' );

And in reset, it does this:

    reset: function() {
      PlinkoProbabilityCommonView.prototype.reset.call( this );
      this.viewProperties.histogramModeProperty.set( 'counter' );
    }

This is a bad way to handle this, because it works correctly only if the order of statements in reset is as shown above. Switch the order and it's wrong.

The correct way to handle this is to provide option histogramMode for PlinkoProbabilityCommonView, default it to 'cylinder', and set it to 'counter' for the Lab screen.