phetsims / energy-skate-park

"Energy Skate Park" is an educational simulation in HTML5, by PhET Interactive Simulations.
MIT License
2 stars 11 forks source link

Code Review #202

Closed jessegreenberg closed 4 years ago

jessegreenberg commented 4 years ago

@ariel-phet @samreid Energy Skate Park is ready for a code review. To assist in review, I wanted to list out the new features and changes which resulted in the largest changes to code. Other than these, the code remained mostly the same from energy-skate-park-basics.

New Features and Important Changes

New files and changes to model inheritance are also described in implementation-notes.md, so I recommend starting with implementation-notes.md and model.md as well.

Next comment will include checklist and references to pre-review issues. Assigning to @ariel-phet as well to comment on review priority. I appreciate it is an especially busy time with ES6 migration!

jessegreenberg commented 4 years ago

PhET Code-Review Checklist (a.k.a "CRC")

GitHub Issues

The following standard GitHub issues should exist. If any of these issues is missing, or have not been completed, pause code review until the issues have been created and addressed by the responsible dev.

GitHub issues should exist that document:

Build and Run Checks

If any of these items fail, pause code review.

Memory Leaks

Performance

Usability

Internationalization

Repository Structure

Coding Conventions

This section deals with PhET coding conventions. You do not need to exhaustively check every item in this section, nor do you necessarily need to check these items one at a time. The goal is to determine whether the code generally meets PhET standards.

For example, both of these are acceptable:

Property.multilink(
  [ styleProperty, activeProperty, colorProperty ],
  ( style, active, color ) => {
    // some algorithm that uses style and active 
} );

Property.multilink(
  [ styleProperty, activeProperty, colorProperty ],
  ( style, active ) => {
    // some algorithm that uses style and active 
} );

This is not acceptable, because the 3rd parameter is incorrect.

Property.multilink(
  [ styleProperty, activeProperty, colorProperty ],
  ( style, active, lineWidth ) => {
    // some algorithm that uses style and active 
} );

Documentation

This section deals with PhET documention conventions. You do not need to exhaustively check every item in this section, nor do you necessarily need to check these items one at a time. The goal is to determine whether the code generally meets PhET standards.

Type Expressions

This section deals with PhET conventions for type expressions. You do not need to exhaustively check every item in this section, nor do you necessarily need to check these items one at a time. The goal is to determine whether the code generally meets PhET standards.

Visibility Annotations

This section deals with PhET conventions for visibility annotations. You do not need to exhaustively check every item in this section, nor do you necessarily need to check these items one at a time. The goal is to determine whether the code generally meets PhET standards.

Because JavaScript lacks visibility modifiers (public, protected, private), PhET uses JSdoc visibility annotations to document the intent of the programmer, and define the public API. Visibility annotations are required for anything that JavaScript makes public. Information about these annotations can be found here. (Note that other documentation systems like the Google Closure Compiler use slightly different syntax in some cases. Where there are differences, JSDoc is authoritative. For example, use Array.<Object> or Object[] instead of Array<Object>). PhET guidelines for visibility annotations are as follows:

Math Libraries

IE11

Organization, Readability, and Maintainability

Accessibility

This section may be omitted if the sim has not been instrumented for a11y.

PhET-iO

This section may be omitted if the sim has not been instrumented for PhET-iO.

samreid commented 4 years ago

I pushed a reference version before the review: https://phet-dev.colorado.edu/html/energy-skate-park/1.0.0-dev.10/phet/energy-skate-park_en_phet.html

samreid commented 4 years ago

Does the sim use Map?

Yes, but its usages look safe. I'll leave it to QA team to test built version on IE.

Does the sim behave correctly when listener order is shuffled?

Difficult to test due to another assertion failure.

Does a heap comparison using Chrome Developer Tools indicate a memory leak?

I don't see a memory leak, but the footprint is relatively large, see #208

The following guidelines should be followed unless there it is obviously no need to unlink, or documentation (in-line or in the implementation nodes)

There are many Property.link without unlink, but I don't think this sim needs the unlinks because most of these cases are static. How should that be documented?

samreid commented 4 years ago

Review complete. Things are generally looking good, nice work! Anything unchecked in the checklist above has one of the following:

In summary, I added 142 // REVIEW comments (note some of these are in the "basics" repo), and opened 28 issues. I also made numerous commits fixing minor problems, typos, formatting, JSDoc, etc. which should be reviewed. Please let me know if you have questions or comments about any parts of the review.

jessegreenberg commented 4 years ago

I had forgotten about this issue, but code review is complete. REVIEW comments were removed and we had some back and forth in dedicated issues sourced from this one, all of which have been closed.