Closed samreid closed 3 months ago
My "note to self" notes to highlight as I continue through the codebase:
To keep in mind as reading through
I'm halfway through common/model. UPDATE up to common/view
Code review is complete. I feel the architecture and overall setup is in good shape. I've opened side issues or TODO comments for recommendations for further improvements.
One difficulty I have in navigating the code is that it is difficult to map from the screen to the code and back. For instance, here is a panel in one of the buoyancy screens:
Since this is an untitled control, it is difficult to know where it lies in the files, and vice versa (looking at the files, difficult to know it is referring to that panel). I'm not sure how to solve that for this case, but it does seem to be less of a problem for the titled panels or titled accordion boxes. Just writing this down as a potential topic to keep in mind for future designs--nothing to do about it at the moment.
Of the remaining TODOs listed for this issue, some are relatively minor and can be addressed here. Others will likely want to move into a dedicated side issue. Some are questions, and some we may decide are not worth the effort. For next steps, can @AgustinVallejo and @zepumph please review the TODOs that reference this issue and take next steps?
We moved all the remaining TODOs into https://github.com/phetsims/density-buoyancy-common/issues/317. Thank you very much @samreid for your thorough review!! Closing
Reopening because there is a TODO marked for this issue.
Reopening because there is a TODO marked for this issue.
Ironic.
Closing again
To familiarize myself better with the codebase, and better prepare for code review, I'll take a look around.
UPDATE:
To begin a code review, the responsible developer should:
dev:code-review
.strikethrough) checklist items and sections that are not relevant.PhET Code-Review Checklist (a.k.a "CRC")
// REVIEW
comments in the codeSpecific Instructions
There are 10 screens across 3 sims. We are publishing with keyboard support but without sonification or interactive description. This simulation uses 2 third party engines. Three.js for 3d rendering and p2 for physics. Review mobius usages as necessary.
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.
brands=phet-io
(if the sim is instrumented for PhET-iO), see {{GITHUB_ISSUE_LINK}}Build and Run Checks
If any of these items fail, pause code review.
ea
)fuzz&ea
)ea&listenerOrder=random
andea&listenerOrder=random&fuzz
)?deprecationWarnings
. Do not use deprecated methods in new code.Memory Leaks
See also https://github.com/phetsims/density-buoyancy-common/issues/168
grunt --minify.mangle=false
. Compare to testing results done by the responsible developer. Results can be found in https://github.com/phetsims/density-buoyancy-common/issues/168.dispose
function, or is it obvious why it isn't necessary, or is there documentation about whydispose
isn't called? An example of why no call todispose
is needed is if the component is used in aScreenView
that would never be removed from the scene graph. Note that it's also acceptable (and encouraged!) to describe what needs to be disposed in implementation-notes.md.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 accompanied byObservableArrayDef.element*Emitter.removeListener
Node.addInputListener
is accompanied byremoveInputListener
PhetioObject
is accompanied bydispose
.dispose
function should have one. This should expose a publicdispose
function that callsthis.dispose{{CLASS_NAME}}()
, wheredispose{{CLASS_NAME}}
is a private function declared in the constructor.{{CLASS_NAME}}
should exactly match the class name.. Will be covered in https://github.com/phetsims/phet-info/issues/224 and https://github.com/phetsims/density-buoyancy-common/issues/168dispose
method from Disposable. Use (b) for classes that inherit adispose
method from something other than Disposable. The goal here is to prevent clients from callingdispose
for something that does not properly clean itself up, creating a memory leak. This is especially important for common code, but is good defensive programming for sim-specific code.Performance
webgl=false
)Usability
showPointerAreas
). UPDATE: Will be addressed in https://github.com/phetsims/density-buoyancy-common/issues/170showPointerAreas
) Overlap may be OK in some cases, depending on the z-ordering (if the front-most object is supposed to occlude pointer areas) and whether objects can be moved. UPDATE: Will be addressed in https://github.com/phetsims/density-buoyancy-common/issues/170Internationalization
stringTest=dynamic
and use the left/right arrow keys.stringTest=X
. You should see nothing but 'X' strings.)stringTest=double
andstringTest=long
)stringTest=xss
? This test passes if sim does not redirect, OK if sim crashes or fails to fully start. Only test on one desktop platform. For PhET-iO sims, additionally test?stringTest=xss
in Studio to make sure i18n strings didn't leak to phetioDocumentation, see https://github.com/phetsims/phet-io/issues/1377StringUtils.fillIn
and a string pattern to ensure that strings are properly localized. This is relevant in cases where order should be translatable."{{value}} {{units}}"
) instead of numbered placeholders (e.g."{0} {1}"
).Repository Structure
[x] 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".
[x] 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.
[x] 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.
[x] 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:
UPDATE: We discussed this in https://github.com/phetsims/density-buoyancy-common/issues/125 and approved a variation
MolarityConstants.js
in molarity. If the repository name is long, the developer may choose to abbreviate the repository name, e.g.EEConstants.js
in expression-exchange. If the abbreviation is already used by another repository, 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".grunt published-README
orgrunt unpublished-README
? Common code repos can have custom README files.{{PREFIX}}QueryParameters.js
, for example ArithmeticQueryParameters.js for the arithmetic repository, or FBQueryParameters.js for Function Builder (where theFB
prefix is used).public: true
in the schema.MyRepoColors.ts
or, if using abbreviations,MRColors.ts
, and useProfileColorProperty
where appropriate, even if they have a single (default) profile (to support color editing and PhET-iO Studio). TheColorProfile
pattern was converted to*Colors.ts
files in https://github.com/phetsims/scenery-phet/issues/515. Please see GasPropertiesColors.ts for a good example.{{PREFIX}}Preferences.ts
, for example KeplersLawsPreferences.ts. The initial value of each such preferences Property should be set via a query parameter from{{PREFIX}}QueryParameters.js
.package.json
refer to any dependencies that are not used by the sim?Coding Conventions
TypeScript Conventions
Math Libraries
DOT/Utils.toFixed
orDOT/Utils.toFixedNumber
should be used instead oftoFixed
. JavaScript'stoFixed
is notoriously 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
Pick
, but this is a bit of a hack. Here's an example:TODO
orFIXME
orREVIEW
comments in the code? They should be addressed or promoted to GitHub issues."todo-should-have-repo"
lint rule enabled.{{REPO}}Constants.js
file?PhetColorScheme
. Identify any colors that might be worth adding toPhetColorScheme
.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
Alternative Input
fuzzBoard&ea
)ScreenView.pdomPlayAreaNode.pdomOrder
andScreenview.pdomControlAreaNode.pdomOrder
to control the traversal order and categorize Nodes in the PDOM? See alternative-input-quickstart-guide.md for more information.Interactive Description
Section deleted because Interactive Description is not supported for this publication.
PhET-iO
This section may be omitted if the sim has not been instrumented for PhET-iO, but is likely good to glance at no matter.
PhetioObject
instances are disposed, which unregisters their tandems.dt
values are used instead ofDate.now()
or other Date functions. Perhaps tryphet.joist.elapsedTime
. Though this has already been mentioned, it is necessary for reproducible playback via input events and deserves a comment in this PhET-iO section.DOT/dotRandom
as an imported module (not a global), and all doing so after modules are declared (non-statically)? For example, the following methods (and perhaps others) should not be used:Math.random
,_.shuffle
,_.sample
,_.random
. This also deserves re-iteration due to its effect on record/playback for PhET-iO.undefined
values are omitted when serializing objects across frames. Consider this when determining whethertoStateObject
should usenull
orundefined
values.enabledProperty
, useAXON/EnabledProperty
. This should be done in both the model and the view. If you're using a DerivedProperty, skip this item.phetioDocumentaton
- it changes the PhET-iO API!