phetsims / number-line-distance

"Number Line: Distance" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
0 stars 3 forks source link

Duplication in Scene view classes. #54

Closed pixelzoom closed 3 years ago

pixelzoom commented 3 years ago

For code review #35.

There's a bit of dupliction in DistanceSceneView, ElevationSceneView, and TemperatureSceneView. You might consider factoring the commonalities out into a NLDSceneView base class.

The bits that they have in common are:

Or maybe the base class is as simple as this:

class NLDSceneView extends Node {

  /**
   * @param {NLDBaseView} baseView
   */
  constructor( baseView ) {
    super();

    // @private 
    this.baseView = baseView;
    this.addChild( baseView );
  }

  // @public
  reset() {
    this.baseView.accordionBoxOpenedProperty.reset();
  }
}
SaurabhTotey commented 3 years ago

I made an NLDSceneView as suggested here, but I made the superclass create the NLDBaseView and the DistanceShadedNumberLineNode. I will close this issue, but feel free to reopen if there is more work to be done.

pixelzoom commented 3 years ago

👍🏻 This looks very nice.