Closed zepumph closed 7 years ago
@samreid do these credits seem alright to you?
credits: {
leadDesign: 'Michael Dubson',
softwareDevelopment: 'Michael Dubson, John Blanco',
team: 'Wendy Adams, Mindy Gratny, Ariel Paul',
thanks: 'Thanks to Mobile Learner Labs for working with the PhET development team\nto convert this simulation to HTML5.'
}
The credits seem reasonable, nothing unexpected jumping out at me.
For each common-code component (sun, scenery-phet, vegas, …) that opaquely registers observers or listeners, is there a call to that component’s dispose function, or documentation about why dispose is unnecessary?
There is no dispose function for the ResistanceInAWireScreenView, but there is this call:
this.addChild( new ResetAllButton( {
listener: function() { model.reset(); },
radius: 30,
right: slidersBox.right,
centerY: slidersBox.bottom + 60
} ) );
I don't think more has to be done here, but there is no documentation about that listener being removed.
@samreid there are just a few points I want to go over with you, otherwise this issue is basically complete.
@samreid please close if you feel like all looks good.
I did some more refactoring in the above commits, SlidersBox still needs attention.
@samreid in https://github.com/phetsims/resistance-in-a-wire/commit/588c5ce7900b8eea7cd4b32dc16f5df46b6a0e57 I noticed that you moved the Node.call()
down to the end of the constructor. I am thinking that that is because the tandem must be passed as the last thing in the constructor.
Could you comment on your implementation vs:
function Slider(){
Node.call( {x:x, y:y . . .}
... all of the constructor
Node.mutate( {tandem: tandem})
I am thinking that that is because the tandem must be passed as the last thing in the constructor.
No, the tandem doesn't need to be last. The main reason for the change was to move from an imperative style to a declarative style. Here's a simplification of the change:
// imperative
var x = new Node();
x.addChild(child1);
x.addChild(child2);
// declarative
var y = new Node({
children: [child1, child2]
});
The main principles for why to prefer the 2nd approach:
addChild
callsaddChild
calls.It is not always possible to use the declarative approach, but it seems generally preferable where applicable.
@veillette did some great work on this front. I think it still needs another pass to make sure all is good. But I think we are close.
@samreid I think this is ready to close, I refactored further and got things pretty crisp and clean. Please have a look and comment if there is more to be done. Thanks!
Things look much better, thanks! 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
{binaryProbability: "Binary Probability"}
. Screen names should use camelcase, like soscreen.screenName
. Message patterns and long paragraphs will also use a different pattern.Repository structure
[x] Are all required files and directories present?
For a sim repository named “my-repo”, the general structure should look like this (where assets/, audio/, images/, or dependencies.json 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.
[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:
grunt published-README
orgrunt unpublished-README
?Coding conventions
Documentation
{{REPO}}QueryParameters
, for example ArithmeticQueryParameters for the aritmetic repository.Math Libraries
dot.Util.roundSymmetric
is used instead ofMath.round
.Math.round
does not treat positive and negative numbers symmetrically, see https://github.com/phetsims/dot/issues/35#issuecomment-113587879.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
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 exactly match the filename.PhET-iO