-
Notifications
You must be signed in to change notification settings - Fork 5
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
Code Review #165
Labels
Comments
jbphet
added a commit
that referenced
this issue
Aug 23, 2023
This was referenced Aug 23, 2023
Closed
This was referenced Aug 23, 2023
This was referenced Aug 24, 2023
Closed
jbphet
added a commit
that referenced
this issue
Aug 24, 2023
jbphet
added a commit
to phetsims/shred
that referenced
this issue
Aug 25, 2023
This was referenced Aug 25, 2023
jbphet
added a commit
to phetsims/shred
that referenced
this issue
Aug 25, 2023
Alright! All review comments have been handled, and the remaining work here is covered by side issues. Thanks @jbphet so much for the thorough and speedy code review. Closing |
zepumph
added a commit
to phetsims/aqua
that referenced
this issue
Aug 28, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PhET Code-Review Checklist (a.k.a "CRC")
// REVIEW
comments in the codeTable of Contents
Specific Instructions
Provide specific instructions here. For example: known problems that will fail CRC items, files that can be skipped,
code that is not completed, shared or common code that also needs to be reviewed,... If there are no specific
instructions, then delete this section.
GitHub Issues
The following standard GitHub issues should exist. If these issues are missing, or have not been completed, pause code
review until the issues have been created and addressed by the responsible dev.
describe the model, in terms appropriate for teachers? Has it been reviewed by the sim designer?
implementation-notes.md. Does it provide an overview that will be useful to future maintainers?
brands=phet
, see Memory test #119Build and Run Checks
If any of these items fail, pause code review.
ea
)fuzz&ea
)parameters
ea&listenerOrder=random
andea&listenerOrder=random&fuzz
)?deprecationWarnings
. Do not use deprecated methods innew code.
Memory Leaks
described here.) Test on a
version built using
grunt --minify.mangle=false
. Compare to testing results done by the responsible developer.Results can be found in {{GITHUB_ISSUE_LINK}}.
there a call to that component’s
dispose
function, or is it obvious why it isn't necessary, or is theredocumentation
about why
dispose
isn't called? An example of why no call todispose
is needed is if the component is used ina
ScreenView
that would never be removed from the scene graph. Note that it's also acceptable (and encouraged!) todescribe what needs to be disposed in implementation-notes.md.
documentation (in-line or in implementation-notes.md) describes why following them is not necessary.
Property.link
orlazyLink
is accompanied byunlink
.Multilink.multilink
is accompanied byunmultilink
.Multilink
is accompanied bydispose
.DerivedProperty
is accompanied bydispose
.Emitter.addListener
is accompanied byremoveListener
.ObservableArrayDef.element*Emitter.addListener
is accompaniedby
ObservableArrayDef.element*Emitter.removeListener
Node.addInputListener
is accompanied byremoveInputListener
PhetioObject
is accompanied bydispose
.dispose
function should have one. This should expose a publicdispose
function thatcalls
this.dispose{{CLASS_NAME}}()
, wheredispose{{CLASS_NAME}}
is a private function declared in theconstructor.
{{CLASS_NAME}}
should exactly match the class name. Reviewer note: The only things disposed in this sim are particles and particle views, and these come from the 'shred' repo and already had dispose functions, so we're good to go.All classes that do not properly overrideReviewer note: N/A since no new classes requiring dispose functions were added.dispose
should either (a) useisDisposable: false
, or (b) implementa
dispose
method that callsDisposable.assertNotDisposable
. Use (a) for classes that inherit adispose
methodfrom Disposable. Use (b) for classes that inherit a
dispose
method from something other than Disposable. The goalhere is to prevent clients from calling
dispose
for something that does not properly clean itself up, creating amemory leak. This is especially important for common code, but is good defensive programming for sim-specific code.
Performance
objects; animation that pauses or "hitches" during garbage collection.
parameter
webgl=false
) _Reviewer comment: Sim does not use WebGL, so we're good to go on this.Usability
showPointerAreas
)showPointerAreas
) Overlap may be OK in some cases, dependingon the z-ordering (if the front-most object is supposed to occlude pointer areas) and whether objects can be moved.
Internationalization
Does the sim behave correctly with dynamic layout, to support dynamic locale? Run with
stringTest=dynamic
anduse the left/right arrow keys.
Are there any strings that are not internationalized, and does the sim layout gracefully handle internationalized
strings that are shorter than the English strings? (run with query parameter
stringTest=X
. You should see nothingbut 'X' strings.)
Does the sim layout gracefully handle internationalized strings that are longer than the English strings? (run
with query parameters
stringTest=double
andstringTest=long
)Does the sim stay on the sim page (doesn't redirect to an external page) when running with the query parameter
stringTest=xss
? This test passes if sim does not redirect, OK if sim crashes or fails to fully start. Only test onone
desktop platform. For PhET-iO sims, additionally test
?stringTest=xss
in Studio to make sure i18n strings didn'tleak
to phetioDocumentation, see https://github.com/phetsims/phet-io/issues/1377
Avoid using concatenation to create strings that will be visible in the user interface. Use
StringUtils.fillIn
and a string pattern to ensure that strings are properly localized. This is relevant in cases where order should be
translatable.
Use named placeholders (e.g.
"{{value}} {{units}}"
) instead of numbered placeholders (e.g."{0} {1}"
).Make sure the string keys are all perfect. They are difficult to change after 1.0.0 is published. They should be
literal, they should be explicit, and they should be consistent. This will also be the PhET-iO phetioID name in Studio
etc. Guidelines for string keys are:
(1) Strings keys should generally match their values. E.g.:
(2) If a string key would be exceptionally long, use a key name that is an abbreviated form of the string value, or
that captures the purpose/essence of the value. E.g.:
(3) If string key names would collide, use your judgment to disambiguate. E.g.:
(4) String keys for screen names should have the general form
"screen.{{screenName}}"
. E.g.:(5) String patterns that contain placeholders (e.g.
"My name is {{first}} {{last}}"
) should use keys that areunlikely to conflict with strings that might be needed in the future. For example, for
"{{price}}"
consider usingkey
"pricePattern"
instead of"price"
, if you think there might be a future need for a"price"
string.(6) It is acceptable to prefix families of strings with a prefix, like so:
Nested substructure is not yet fully supported.
make sure any changes have a good reason and have been discussed with @jbphet (it is likely that an issue
like Translations will lose some strings the next time this is published off of master gravity-force-lab#166 should be created).
Repository Structure
The repository name should correspond to the sim title. For example, if the sim title is "Wave Interference", then
the repository name should be "wave-interference".
Are all required files and directories present?
For a sim repository named “my-repo”, the general structure should look like this (where assets/, images/, mipmaps/ or
sounds/ may be omitted if the sim doesn’t have those types of resource files).
*Any images used in model.md or implementation-notes.md should be added here. Images specific to aiding with
documentation do not need their own license.
Verify that the same image file is not present in both images/ and mipmaps/. If you need a mipmap, use it for all
occurrences of the image.
Is the js/ directory properly structured?
All JavaScript source should be in the js/ directory. There should be a subdirectory for each screen (this also
applies for single-screen sims, where the subdirectory matches the repo name). For a multi-screen sim, code shared by
2 or more screens should be in a js/common/ subdirectory. Model and view code should be in model/ and view/
subdirectories for each screen and common/. For example, for a sim with screens “Introduction” and “Lab”, the general
directory structure should look like this:
Do filenames use an appropriate prefix? Some filenames may be prefixed with the repository name,
e.g.
MolarityConstants.js
in molarity. If the repository name is long, the developer may choose to abbreviate therepository name, e.g.
EEConstants.js
in expression-exchange. If the abbreviation is already used by anotherrepository, then the full name must be used. For example, if the "EE" abbreviation is already used by
expression-exchange, then it should not be used in equality-explorer. Whichever convention is used, it should be used
consistently within a repository - don't mix abbreviations and full names. The abbreviation should be all uppercase
letters; e.g. MOTHAConstants, not MotHAConstants for "Model of the Hydrogen Atom".
fullNuclideChart.png
image? #180 Is there a file in assets/ for every resource file in sound/ and images/? Note that there is not necessarily a1:1 correspondence between asset and resource files; for example, several related images may be in the same .ai file.
Check license.json for possible documentation of why some resources might not have a corresponding asset file.
❌ The README file needs to be updated, see Update the README file #181 For simulations, was the README.md generated by
grunt published-README
orgrunt unpublished-README
? Commoncode repos can have custom README files.
Does package.json refer to any dependencies that are not used by the sim?
Is the LICENSE file correct? (Generally GPL v3 for sims and MIT for common code,
see this thread for additional information).
Does .gitignore match the one in simula-rasa?
In GitHub, verify that all non-release branches have an associated issue that describes their purpose.
Are there any GitHub branches that are no longer needed and should be deleted?
Sim-specific query parameters (if any) should be identified and documented in one .js file in js/common/ or js/ (
if there is no common/). The .js file should be named
{{PREFIX}}QueryParameters.js
, for exampleArithmeticQueryParameters.js for the arithmetic repository, or FBQueryParameters.js for Function Builder (where
the
FB
prefix is used).Query parameters that are public-facing should be identified using
public: true
in the schema.All sims should use a color file named
MyRepoColors.ts
or, if using abbreviations,MRColors.ts
, anduse
ProfileColorProperty
where appropriate, even if they have a single (default) profile (to support color editingand PhET-iO Studio). The
ColorProfile
pattern was converted to*Colors.ts
files inPhET-iO instrumentation for ColorProfile scenery-phet#515. Please see
GasPropertiesColors.ts
for a good example.
Coding Conventions
PhET's Coding Conventions Document followed and adhered to? This document 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.
TypeScript Conventions
the TypeScript Conventions Document
followed and adhered to?
Math Libraries
DOT/Utils.toFixed
orDOT/Utils.toFixedNumber
should be used instead oftoFixed
. JavaScript'stoFixed
isnotoriously buggy. Behavior differs depending on browser, because the spec doesn't specify whether to round or floor.
IE11
string.includes
andstring.startsWith
where possible.Organization, Readability, and Maintainability
expect (or guess!) by looking at the sim? Do the names of things correspond to the names that you see in the user
interface?
See phet-software-design-patterns.md.
If new or inappropriate patterns are identified, create an issue.
See https://en.wikipedia.org/wiki/Composition_over_inheritance.
properties/functions). If you only need a few fields from a large object, pass them in as separate parameters. The threshold for
the number of parameters is up to you - use your judgement. Alternatively in TypeScript, you can decouple by narrowing the API using
Pick
, but this is a bit of a hack. Here's an example:instead of passing the object itself)?
responsibilities be broken into smaller delegates? To see file sizes for TypeScript sims, run this shell command:
Code > Analyze Code > Locate Duplicates and https://github.com/danielstjules/jsinspect.
Are there any
TODO
orFIXME
orREVIEW
comments in the code? They should be addressed or promoted to GitHubissues.
out as constants and documented?
a
{{REPO}}Constants.js
file?constants that might be changed in the future. (Use your judgement about which constants are likely candidates.) Does
changing the values of these constants break the sim? For example,
see allow minimum rows to go to "1" and address dependency on current minimum of "5" plinko-probability#84.
appropriate? Verify that the sim is not inventing/creating its own colors for things that have been standardized
in
PhetColorScheme
. Identify any colors that might be worth adding toPhetColorScheme
.DerivedProperty
instead ofProperty
?help support Legends of Learning and PhET-iO.
Accessibility
This section may be omitted if the sim has not been instrumented with accessibility features. Accessibility includes
various features, not all are always include. Ignore sections that do not apply.
General
requires upfront refactoring. Reviewer note: The sim has keyboard nav, but no description, voicing, or sound, so I just looked at things like pdomOrder, which seemed fine.
Alternative Input
fuzzBoard&ea
)modifier keys like in Unintended zoom/keyboard behavior ratio-and-proportion#287. NOTE: There is currently no list
of global shortcuts, and therefore no way to complete this checklist item.
See Create a list of global keyboard shortcuts. phet-info#188. Reviewer note: There don't appear to be any sim-specific keyboard shortcuts, so this is good to go.
Node.pdomOrder
used appropriately to maintain visual and PDOM layout balance?The text was updated successfully, but these errors were encountered: