-
Notifications
You must be signed in to change notification settings - Fork 6
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 #51
Comments
I see constants that are basically hard coded in terms of the layout. It seems like changing them would definitely screw up this statically laid out sim. There is a good chance that we don't care though, because the layout never changes. |
There are no dispose calls in this sim, nor is unlink ever called, but it is documented well in all places that everything exists for the lifetime of the sim. I think this is fine. |
I think that this code review is done. I got help from @jessegreenberg on some questions I had, and from here I will move on to #50 and then releases of phet-io and phet branded versions. Closing |
NOTE! Prior to doing a code review, copy this checklist to a GitHub issue for the repository being reviewed.
PhET code-review checklist
Build and Run Checks
Internationalization
generally match the values, such as
{binaryProbability: "Binary Probability"}
. Screen names should use camelcase, like soscreen.screenName
. For patterns that contain placeholders (e.g."My name is {{first}} {{last}}"
) choose keys that are unlikley to conflict with strings that might be needed in the future. For example, for"{{price}}"
consider using key"pricePattern"
instead of"price"
, if you think there might be a future need for a"price"
string.Repository structure
For a sim repository named “my-repo”, the general structure should look like this (where assets/, audio/ or images/ may be omitted if the sim doesn’t have those types of assets).
For a common-code repository, the structure is similar, but some of the files and directories may not be present if the repo doesn’t have audio, images, strings, or a demo application.
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:
1:1 correspondence between asset and resource files; for example, several images may be in the same .ai file.
grunt published-README
orgrunt unpublished-README
?Coding conventions
grunt update-copyright-dates
.[\w]+\.[\w]+\s=
[\w]+: function\(
Documentation
{{REPO}}QueryParameters
, for example ArithmeticQueryParameters for the aritmetic repository.@author
annotations seem correct?Math Libraries
dot.Util.roundSymmetric
is used instead ofMath.round
.Math.round
does not treat positive and negative numbers symmetrically, see fix nearest-neighbor rounding in Util.toFixed dot#35 (comment).dot.Util.toFixed
ordot.Util.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.phet.joist.random
, and are doing so after modules are declared (non-statically). For instance, the following methods (and perhaps others) should not be used:Math.random
_.shuffle
_.sample
_.random
new Random()
Organization, Readability, Maintainability
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.
Performance, Usability
dt
capped appropriately? Try switching applications or browser tabs, then switch back. Did the model take one big/long/awkward step forward? If so,dt
may need to be capped. Example fromfaradays-law.FaradaysLawModel
:Memory Leaks
Property.link
is accompanied byProperty.unlink
.PropertySet.link
is accompanied byPropertySet.unlink
.DerivedProperty
is accompanied bydispose
.Multilink
is accompanied bydispose
.Events.on
is accompanied byEvents.off
.Emitter.addListener
is accompanied byEmitter.removeListener
.Node.on
is accompanied byNode.off
tandem.addInstance
is accompanied bytandem.removeInstance
.dispose
function have one? This should expose a publicdispose
function that callsthis.disposeMyType()
, wheredisposeMyType
is a private function declared in the constructor.MyType
should exactlymatch the filename.
PhET-iO
for the PhET-iO development process.
The text was updated successfully, but these errors were encountered: