phetsims / example-sim

Example demonstrating the structure of a PhET interactive simulation.
http://scenerystack.org/
GNU General Public License v3.0
14 stars 27 forks source link

Bring code up to current standards #6

Closed samreid closed 6 years ago

samreid commented 6 years ago

We use example-sim as a reference in test tasks, and it should be brought up to our new level of standards as other sims according to the https://github.com/phetsims/phet-info/blob/master/checklists/code_review_checklist.md

Issues in particular that need to be addressed:

  1. We need to add visibility annotations on property assignment like @public, @private, etc.
  2. Each property should be documented.
  3. Better JSdoc for functions

For example, Bar Magnet's size property should get a comment like:

    // @public {Dimension2} - the size of the bar magnet in model cooordinates 
    this.size = size;

And BarMagnet's reset function should get JSDoc like:

    /**
     * Restores the initial state of the BarMagnet. This method is called when the simulation "Reset All" button is 
     * pressed.  Note that the BarMagnet.size size is constant and does not need to be reset.
     * @public
     */
    reset: function() {
      this.locationProperty.reset();
      this.orientationProperty.reset();
    }
phet-steele commented 6 years ago

@samreid I took a stab at this in the above commits, please review. If there is more to do, don't tell me what to change. Instead just say, "You're missing something" so I can attempt to find it myself first 😄.

Also please ignore the changes to package.json in 054565d8725429740230f41041f9eb3c1fc946cf (the first commit). That was a mistake that was reverted.

samreid commented 6 years ago

Looks great @phet-steele, some minor recommendations:

phet-steele commented 6 years ago

I hardly feel like I should be the author in any of these, but I especially don't think I should be in ExampleScreen.js. I added myself as author to all but that file.

@samreid recommendations have been done in the above commits. Please review and close!

samreid commented 6 years ago

Excellent work, thanks! Closing.