heldentodd / xray-diffraction

This repository contains the code for one simulation, but eventually three are planned: bragg-law, Single Crystal Diffraction, and Powder Diffraction.
GNU General Public License v3.0
2 stars 1 forks source link

PhET code review #1

Open pixelzoom opened 4 years ago

pixelzoom commented 4 years ago

@ariel-phet asked me to do a code review of this sim, using the PhET Code-Review Checklist. I've removed 3 sections from that checklist that are not relevant here: GitHub Issues, Accessibility, and PhET-iO. Any GitHub issues that I create that are related to this review will be linked to this GitHub issue.


PhET Code-Review Checklist (a.k.a "CRC")

Build and Run Checks

If any of these items fail, pause code review.

Memory Leaks

Performance

Usability

Internationalization

Repository Structure

Coding Conventions

This section 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.

For example, both of these are acceptable:

Property.multilink(
  [ styleProperty, activeProperty, colorProperty ],
  ( style, active, color ) => {
    // some algorithm that uses style and active
} );

Property.multilink(
  [ styleProperty, activeProperty, colorProperty ],
  ( style, active ) => {
    // some algorithm that uses style and active
} );

This is not acceptable, because the 3rd parameter is incorrect.

Property.multilink(
  [ styleProperty, activeProperty, colorProperty ],
  ( style, active, lineWidth ) => {
    // some algorithm that uses style and active
} );

Documentation

This section deals with PhET documention 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.

Type Expressions

This section deals with PhET conventions for type expressions. 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.

Visibility Annotations

This section deals with PhET conventions for visibility annotations. 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.

Because JavaScript lacks visibility modifiers (public, protected, private), PhET uses JSdoc visibility annotations to document the intent of the programmer, and define the public API. Visibility annotations are required for anything that JavaScript makes public. Information about these annotations can be found here. (Note that other documentation systems like the Google Closure Compiler use slightly different syntax in some cases. Where there are differences, JSDoc is authoritative. For example, use Array.<Object> or Object[] instead of Array<Object>). PhET guidelines for visibility annotations are as follows:

Math Libraries

IE11

Organization, Readability, and Maintainability

pixelzoom commented 4 years ago

Code review is completed. Overall this sim is in nice shape - an impressive accomplishment from someone working independently! I created a bunch of GitHub issues, all linked to this issue. Back to @heldentodd. Let me know if you have any questions.

@Ariel-phet FYI.

heldentodd commented 4 years ago

Thank you so much. I've glanced at the comments. Some were expected, others were not. It really organizes what I need to do to fix up the code. I will be working on it starting today as soon as I figure out how to use github properly with the copy I have locally.

heldentodd commented 4 years ago

I've made some changes to the interface and added a few new bells and whistles after discussions with @ariel-phet. The code is feature complete for now, so I will be going over the code review items one more time. I'm hopeful that I won't find any new issues.

The next step for me will probably be to implement rotation of the crystal, which will take some time. That will probably be on a new screenview though.

heldentodd commented 4 years ago

OK, I've been over the code review list again. I addresses a few minor issues I found.

The only thing I found that I didn't address is an issue that only manifests when I run the simulation with query parameters ea&shuffleListeners. The protractor and its tool icon can sometimes both disappear after being moved off then back onto the toolbox several times. This never happens without these parameters, so perhaps it is a non-issue. I checked and the “Bending Light” PhET (from which I stole the protractor code) does the same thing.

heldentodd commented 4 years ago

Thank you once again to @pixelzoom! I have learned a lot, and the code is now much more likely to be maintainable and useful to other. This is really going to help me with my upcoming plans.

pixelzoom commented 4 years ago

The only thing I found that I didn't address is an issue that only manifests when I run the simulation with query parameters ea&shuffleListeners. The protractor and its tool icon can sometimes both disappear after being moved off then back onto the toolbox several times. ...

Thanks, I've added this to the work list in https://github.com/phetsims/scenery-phet/issues/609#issuecomment-644899719.

Thank you ...

You're most welcome! If you have any other questions, don't hesitate to reach out.

And feel free to close this issue whenever suits you.