Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

where should Ranges for NumberProperties live? #279

Closed
pixelzoom opened this issue Dec 19, 2018 · 4 comments
Closed

where should Ranges for NumberProperties live? #279

pixelzoom opened this issue Dec 19, 2018 · 4 comments

Comments

@pixelzoom
Copy link
Contributor

pixelzoom commented Dec 19, 2018

Related to code review #259.

This started as several REVIEW comments, but it's gotten complicated, so creating this issue.

This issue applies to NumberProperty instances in Scene, WaterScene, and (possibly) DiffractionModel.

Ranges for many (all?) model NumberProperties are not not specified. Instead, they are associated with the UI components.

For example, in Scene:

      //REVIEW add value validation?
      //REVIEW* the model supports any value, though going outside the bounds of the lattice would probably be a logic
      //REVIEW* error.  The view slider has its own constraint.  Which value should I use here?
      // @public distance between the sources in the units of the scene, or 0 if there is only one
      // source initialized to match the initial slit separation,
      // see https://github.com/phetsims/wave-interference/issues/87
      this.sourceSeparationProperty = new NumberProperty(
        config.numberOfSources === 1 ? 0 : config.initialSlitSeparation, {
          units: this.positionUnits
        } );

A few issues with not providing Ranges with these NumberProperties, considering future PhET-iO requirements:

(1) How can these model Properties be instrumented (with a slider) in Studio if no Range is provided?

(2) When inspecting these model Properties in Studio, there will be no Range info found.

(3) The Ranges are currently spread out across view components, rather than being in the model with their associated Properties. For example, 6 of the Ranges are in SlitsControlPanel (search for "new Range"). These Ranges would presumably need to be instrumented explicitly to make them visible in Studio.

(4) One could argue that specifying Ranges in the UI components violates MVC. Info needed by controls should come from the model.

(5) The current pattern is contrary to what's done in other sims. This may be confusing to Studio users.

pixelzoom added a commit that referenced this issue Dec 19, 2018
@pixelzoom
Copy link
Contributor Author

pixelzoom commented Dec 19, 2018

Also worth noting that there is inconsistency here; some NumberProperty instances do have Range specified in the model. See for example frequencyProperty and amplitudeProperty in Scene. Why the different treatment?

pixelzoom added a commit that referenced this issue Dec 19, 2018
pixelzoom added a commit that referenced this issue Dec 19, 2018
@pixelzoom
Copy link
Contributor Author

pixelzoom commented Dec 19, 2018

Here are the Ranges in question, currently in the view:

// InteferenceScreenView
const waterSceneRange = new Range( 1, 5 ); // cm
const soundSceneRange = new Range( 100, 400 ); // cm
const lightSceneRange = new Range( 500, 4000 ); // nm

// SlitsControlPanel
const waterRange = new Range( 0.5, 2.5 ); // cm
const soundRange = new Range( 20, 160 );
const lightRange = new Range( 200, 1600 );
const waterSeparationRange = new Range( 1, 5 );
const soundSeparationRange = new Range( 40, 320 ); // cm
const soundSeparationRange = new Range( 40, 320 ); // cm
const lightSeparationRange = new Range( 400, 3200 );

There are 6 more in DiffractionScreenView, but we're ignoring that screen for 1.0.

@samreid
Copy link
Member

samreid commented Dec 21, 2018

Good suggestion, I specified the Ranges in the model. Please review.

@pixelzoom
Copy link
Contributor Author

👍 Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants