-
Notifications
You must be signed in to change notification settings - Fork 3
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 #125
Comments
@AgustinVallejo This sim is ready for code review. Let me know if you'd like to meet to discuss. Note that I'm still working on #115, debugging and optimizing the Schrodinger view. So please skip these 3 files in your review:
|
@AgustinVallejo and I had a kick-off meeting at 11:00AM on 2/11/2025. |
2025-02-17: Today I'm fully starting the review process. Below is a checklist of things that should be addressed:
@pixelzoom: ... as noted in #125 (comment). I’ll be wrapping that up today.
While all of these have the value
@pixelzoom: Changed to 'Schrödinger' when it appears in comments and is not included in the name of a class. See d3de41f.
You were probably looking at an old implementation of the Schrodinger view, before #129 was completed. The new implementation achieves smooth orbitals with small grid sizes. Test protocol: #129 (comment) And in MOTHAQueryParameters: gridSize: {
type: 'number',
defaultValue: 35, // See https://github.com/phetsims/models-of-the-hydrogen-atom/issues/129#issuecomment-2670189907
isValidValue: value => Number.isInteger( value ) && ( value >= 10 )
},
You are confusing declaration and definition, probably because coding-conventions.md is unclear about the distinction. coding-conventions.md is referring to definition, which is where the object is instantiated and assigned to a field. This is where you should be using Declarations (of fields, parameters, return types,...) should generally use less-specific types, with the appropriate type that provides read-only or write access as needed. These type definitions are Let me know if you need further clarification about this topic.
@pixelzoom: Addressed in #133. |
@AgustinVallejo The Schrodinger view implementation is complete, so all files are now ready for review. |
@AgustinVallejo said:
Thanks, fixed in 8567423. Screenshot below. ![]() |
…ow relevant to more than KeyboardDragListener, #125
@AgustinVallejo Thanks for the There are 2 In BohrModel.ts: // Minimum time (in sec) that the electron must be in a state before transitions can occur.
// REVIEW: Since this is time to absorption OR emission, would rename to something more general like MIN_TIME_IN_STATE_BEFORE_TRANSITION https://github.com/phetsims/models-of-the-hydrogen-atom/issues/125
const MIN_TIME_IN_STATE_BEFORE_ABSORPTION = 0.75;
const MIN_TIME_IN_STATE_BEFORE_STIMULATED_EMISSION = 1;
const MIN_TIME_IN_STATE_BEFORE_SPONTANEOUS_EMISSION = 1; This is NOT "time to absorption OR emission". These are the individual times for absorption and 2 types of emission (stimulated and spontaneous). They each require a separate In SchrodingerQuantumNumbers.ts: // This should match STATE_SCHEMA, but with JavaScript types.
type SchrodingerQuantumNumbersStateObject = {
n: number;
l: number;
m: number;
};
// This should match SchrodingerQuantumNumbersStateObject, but with IOTypes.
// REVIEW: Should an assertion or test be added to ensure these two matching? https://github.com/phetsims/models-of-the-hydrogen-atom/issues/125
const STATE_SCHEMA = {
n: NumberIO,
l: NumberIO,
m: NumberIO
}; SchrodingerQuantumNumbersStateObject is a TypeScript type, so there is no way that I can assert/test that it matches STATE_SCHEMA. If they do not match, TypeScript will complain, or (worst case) PhET-iO will fail, and that seems sufficient. |
@AgustinVallejo I addressed the items in #125 (comment) and made notes in that comment. Let me know if you'd like to discuss any of those. |
I guess this one is a bit unclear with all the Tier 1 stuff going on, but I will consider it done:
|
Code review is done! Back to @pixelzoom for future steps. |
Thanks @AgustinVallejo! We discussed a few topics this morning via Zoom. And I have addressed the remaining REVIEW issues (see above commits). So closing. |
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.
Build 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 in new code.Memory Leaks
grunt --minify.mangle=false
. Compare to testing results done by the responsible developer. Results can be found in #120.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 accompaniedby
ObservableArrayDef.element*Emitter.removeListener
Node.addInputListener
is accompanied byremoveInputListener
PhetioObject
is accompanied bydispose
.dispose
function should have one. There are many reasonable ways to implementdispose
, including but not limited to: (a) declaring a private function likethis.dispose{{CLASS_NAME}}()
in the constructor, where{{CLASS_NAME}}
should exactly match the class name. (b) Using Disposable.ts/disposeEmitter, (c) callingsuper.dispose()
andmyChild.dispose()
etc.dispose
should either (a) useisDisposable: false
, or (b) implement adispose
method that callsDisposable.assertNotDisposable
. Use (a) for classes that inherit adispose
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
If the sim uses WebGL, does it have a fallback? Does the fallback perform reasonably well? (run with query parameterwebgl=false
)Usability
showPointerAreas
)showPointerAreas
) 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.Internationalization
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}"
).${REPO}-strings_en.json
and verify that all string keys conformto string key conventions. String keys are difficult to change after a sim has been published, and they appear in the PhET-iO API (and Studio) as the phetioIDs for StringProperties.
If the sim was already released, make sure none of the original string keys have changed. If they have changed, 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 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".Is there a file in assets/ for every resource file in sounds/ and images/? Note that there is not necessarily a 1: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.
For simulations, was the README.md generated by
grunt published-README
orgrunt unpublished-README
? Common code repos can have custom README files.Is the LICENSE file correct? (Generally GPL v3 for sims and MIT for common code, see this thread for additional information). Note that "common" repos that are mostly sim-specific code (like circuit-construction-kit-common and density-buoyancy-common) should be GPL v3, see other thread.
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 example ArithmeticQueryParameters.js for the arithmetic repository, or FBQueryParameters.js for Function Builder (where theFB
prefix is used).Query parameters that are public-facing should be identified usingpublic: true
in the schema.All sims should use a color file named
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 PhET-iO instrumentation for ColorProfile scenery-phet#515. Please see GasPropertiesColors.ts for a good example.Sim-specific preferences (which appear in the Simulation tab of the Preferences dialog) should appear as Properties in{{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
.Does
package.json
refer to any dependencies that are not used by the sim?Does
package.json
,tsconfig.json
, oreslint.config.mjs
include any config that was only needed for development? For example:Coding 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
.DerivedProperty
instead ofProperty
?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.HotkeyData
. Both the KeyboardListener and keyboard help dialog content should use theHotkeyData
. This factors used keys into a single location and supports auto-generated documentation about used keys.Interactive Description
Run the entire built sim HTML file through an HTML validator, does the HTML pass?See HTML validator results in many Error/Warning/Info messages. scenery#1687.toUpperCase()
. Remember that one day these strings will be translatablePhET-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!The text was updated successfully, but these errors were encountered: