phetsims / number-play

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

Game Screen: code review #84

Closed chrisklus closed 1 year ago

chrisklus commented 2 years ago

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

Specific Instructions

Only the Game screen should be reviewed, all of which is in TypeScript. NumberPlayConstants.js and NumberPlayQueryParameters.js also have relevant parts to the Game, so those parts should be included in the review even though they are still in JavaScript. Any other common files that the Game relies on, like OnesPlayArea.js and OnesPlayAreaNode.js, should not be included in the review.

GitHub Issues

Build and Run Checks

If any of these items fail, pause code review.

Memory Leaks

NOTE: There is a memory leak, which we suspect is related to the paper numbers. These are used in the game, but have not been refactored yet, so they should not be addressed in the Game review.

Performance

Usability

Internationalization

  "material.water": {
    "value": "Water"
  },
  "material.wood": {
    "value": "Wood"
  },
  "shape.block": {
    "value": "Block"
  },
  "shape.cone": {
    "value": "Cone"
  },

Nested substructure is not yet fully supported.

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 documentation 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.

/**
 * Updates this node.
 * @abstract
 * @protected
 */
 update() {
   throw new Error( 'update must be implemented by subclass' );
 }

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

chrisklus commented 2 years ago

@Luisav1 and I went through her self-code review checklist in #75 and made this issue from it. When ready to proceed, @Luisav1 will assign CM to start the review.

Luisav1 commented 2 years ago

@pixelzoom The game screen is ready for review. Please note the special instructions at the top and reach out to us on slack if you have any questions.

Something we noticed during my review was that a lot of the coding conventions haven't been updated for TypeScript. Please let us know if you'd prefer for us to do our best in updating this list before you review, or perhaps you can review TypeScript the best you know how and we can update the list later when TypeScript is more widely used by PhET.

pixelzoom commented 2 years ago

Thanks. Special instructions read and understood. No need to update the checklist for TypeScript.

pixelzoom commented 2 years ago

I've complete the code-review checklist, and I also checked typescript-conventions.md. I created a number of issues (linked above), but most of them are relatively minor. The one issue that does concern me is #92, the gameLevels query parameter.

Overall the code is in nice shape. Easy to understand, and well-documented. Well done!

Back to @Luisav1, let me know if you have any questions.

Luisav1 commented 2 years ago

Thanks @pixelzoom for reviewing this! I'll let you know if any questions come up. Would you like me to assign the issues back to you or back to @chrisklus for review?

pixelzoom commented 2 years ago

If @chrisklus has time to review, that would be preferrable. But if he doesn't have time, or something needs futher input/discussion, feel free to assign back to me.

chrisklus commented 1 year ago

The remaining work for this issue applied to the whole sim, not just the game screen, and is being tracked elsewhere. Closing.