phetsims / number-line-integers

"Number Line: Integers" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
0 stars 4 forks source link

Code Review #119

Closed marlitas closed 11 months ago

marlitas commented 1 year ago

Code review to be performed by @zepumph to check on the following:

zepumph commented 1 year ago
zepumph commented 1 year ago

Message Deleted, I was wrong and this is already done.

zepumph commented 1 year ago

added 11/20:

zepumph commented 1 year ago

I made it to ExplorersWrapper today.

zepumph commented 12 months ago

I looked through all NLI-specific changes, and next I will look at changes in number-line-common.

zepumph commented 12 months ago

Alright I have gone through the common and distance number line repos to inspect changes. I played with the number-line-integers sim, looking for spots where the character sets and or dynamic locale seemed wrong or strange. I also worked with @marlitas over in https://github.com/phetsims/joist/issues/943 to familiarize myself with the common code for region and culture. Things are looking really good! Thanks for all you hard work @marlitas and let me know if you have any other thoughts or want to sync up about anything.

marlitas commented 12 months ago

I see that you added a color profile. Can you explain the motivation for this? Only interested as it pertains to the code review, since I'm getting my bearings on what the scope of the changes are.

Mostly because I thought that's the new pattern for color constants in sims. If that's how things are moving forward I thought it was an easy thing to create and add in with minor implications...

I strongly recommend against the word "wrapper" for ExplorersWrapper. I understand why it was used, but can we come up with something without so much baggage?

Totally fine with a rename... What about ExplorersController?

Should character sets be in a separate directory?

I was wondering about this... It felt strange to add another directory on top of model and view just for character sets though. It feels like it would break that pattern.

Instead of ExploresWrapper.createVisibleProperty() can you use DerivedProperty.valueEqualsConstant?

Sure, never used it before :-)

I think it would be nice to have a central spot where all supported region and culture values are defined, and to be able to have some brief documentation (in code) about what the target of each is. I'm writing this because I'm a little confused about what to expect in Multicultural. Perhaps here: https://github.com/phetsims/joist/blob/e61c11c6bfd0481bba8c26fe110e3febd23ba3ef/js/preferences/RegionAndCulturePortrayal.ts#L31-L37. This is probably has much more design nuance and I don't think we need to go overboard, but just something about the target for this style.

I can bring this up with AM. There's been a lot of discussion about this from a design perspective throughout.

It is sad to have lost the git history for PiggyBankNode, but probably not worth trying to resurrect it at this point (piggyBankShapes too).

Oh bummer, I'm sorry. I need to be better about checking on that with renames. I tend to forget about preserving the git history. Thanks for the reminder.

If they are in this range I strongly recommend that TypeScript conversion accompany this.

I agree I will do this moving forward.

marlitas commented 12 months ago

Remainder TODO:

zepumph commented 12 months ago

Totally fine with a rename... What about ExplorersController?

How about Explorer. Where it could have like Explorer.flying, etc. Another idea if we still like the suffix, "Character" or "CharacterSet"? It seems to fit with how we talk about region and culture and design speak. Perhaps I'm wrong though and that means something else. One sim could have three Character subtypes for africa (an explorer, a banker, etc). Each "Character" can have different visuals associated with it. Just a thought, no strong preference.

I was wondering about this... It felt strange to add another directory on top of model and view just for character sets though. It feels like it would break that pattern.

What about inside the view? explore/view/characters/

marlitas commented 11 months ago

How about Explorer. Where it could have like Explorer.flying, etc. Another idea if we still like the suffix, "Character" or "CharacterSet"?

I'm not a fan of Explorer, it sounds kind of model-ey to me. We had Kicker and KickerNode in CAV with Kicker being the model. I think ExplorerCharacters could work. I think plural would be helpful since it really is organizing and managing all of the explorers. I'll go ahead and make that change.

What about inside the view? explore/view/characters/ Love it.

zepumph commented 11 months ago

ExplorerCharacters

Can you help me understand where this class fits into the notion of a "character set"? Isn't this a single character in that set (now a portrayal)? Like you choose "usa", and then that sets a property to this class, so I'm worried that having two things that both have some semblance of plurality may be more confusing on the general preference side, even though it may be less confusing for the usages.

Part of this code review is to really lock in the definitions of the feature. RegionAndCulturePortrayal is not longer called "CharacterSet", that must have been done for a reason, so perhaps let's name this subtype to match that decision. Maybe now, after the rename, that actually frees up the term "Characters" to be best used to describe all the different entitires in the portrayal.

ugg. Thanks for letting me talk out loud.

Still think Characters is best? I think I just might!

marlitas commented 11 months ago

Can you help me understand where this class fits into the notion of a "character set"?

In the context of this sim it is three separate versions of the same character. So maybe ExplorerVersions?

In an ideal world I would refactor NLI to have an ExplorerNode that the PointController can just pull in and know how to handle. But in the spirit of disturbing the architecture as little as possible this ExplorerCharacters class was born. It is not a class that I would expect to be needed in every sim, and currently NLI is the only one I know for sure needs it. I believe LV added it into the Area Model sims just in case, but we haven't dug into the code enough to find out if it's actually needed there.

RegionAndCulturePortrayal is not longer called "CharacterSet", that must have been done for a reason, so perhaps let's name this subtype to match that decision.

Yeah I've been wondering about that, and was kind of dreading doing it until someone else pointed it out. You're right though. CM was confused when he saw RegionAndCultureCharacterSet, thinking that they were alphabet characters and not cartoon characters. That's when we changed to portrayal. I think that's probably more accurate and prone to less confusion... Fine I'll change it. 😅

Still think Characters is best? I think I just might!

Maybe... but I'm also not hating Versions... I also am getting to the point where my brain doesn't care and is fine with whatever name you throw at me... I'd probably be good with Potato at this point... 🤷🏽

marlitas commented 11 months ago

REVIEW, were all of these changed because of dynamic layout? Can you describe to me why they needed to be changed, and add doc about that if you think it is helpful.

const COIN_DEPOSIT_ANIMATION_START_Y = -95; // above the money jar, in screen coordinates, empirically determined
const COIN_DEPOSIT_ANIMATION_END_Y = -60; // inside the money jar, in screen coordinates, empirically determined
const COIN_WITHDRAWAL_ANIMATION_START_Y = 70; // inside the money jar, in screen coordinates, empirically determined
const COIN_WITHDRAWAL_ANIMATION_END_Y = 95; // below the money jar, in screen coordinates, empirically determined
...
const coinClipArea = Shape.rectangle( -100, -150, 200, 300 );
coinClipArea.moveTo( -20, -69 );
coinClipArea.lineTo( -20, 78 );
coinClipArea.lineTo( 20, 78 );
coinClipArea.lineTo( 20, -69 );
coinClipArea.close();
coinAnimationLayer.clipArea = coinClipArea;

These were changed because the artwork changed from a piggy bank to a money jar. I did update the documentation to reference the money jar now, but I don't know if any other documentation would be helpful.

marlitas commented 11 months ago

@Luisav1 can you help me with renaming any classes that extend RegionAndCulturePotrayal from CharacterSet to Portrayal? For example: ExplorerCharacterSet would become ExplorerPortrayal. We have to do this in the following repos:

marlitas commented 11 months ago

I had a hard time getting specific descriptions from designers on each region and culture portrayal so I went ahead with a basic description that I hope helps, but not quite sure it solves what @zepumph was hoping for.

I believe all the code review items have now been addressed. Over to @zepumph to look over and close if all looks well.

zepumph commented 11 months ago

Thanks! This is all looking really great. I definitely know how annoying it can be to handle a rename so late in the process of creating (one of my sims was renamed about 2 months after initial development #neverforget).

marlitas commented 11 months ago

@Luisav1 can you update the characterSets terminology in Balancing Act? I know you've been working there, so I didn't want to interfere.

Once that's wrapped up we can assign to @zepumph again.

Luisav1 commented 11 months ago

Oops, I forgot we are going with portrayals now. It's all renamed in Balancing Act. Assigning back to @zepumph.

zepumph commented 11 months ago

Thanks for you patience here as we solidify this.

marlitas commented 11 months ago

In this paragraph it mentions that this is still being developed. To me it seems out of date, and we should just say what is currently in the panel. It is good stuff! Let's be confident about it in its current state.

It's talking about the localization tab in general which is true. It is still being developed and it's current state is definitely more of a "this works until we have time to finish it." I would not say that any designer feels it is completed.

marlitas commented 11 months ago

More generally, @pixelzoom mentioned on slack that it may be nice to add to the doc ad the top of RegionAndCulturePortrayal to mention that it can be more than just character artwork that changes.

I added the description used in the sim. Not sure if it does enough, but there are multiple places that state: "Portrayals of people, places, or objects"

marlitas commented 11 months ago

This should all be addressed. Back to @zepumph and @pixelzoom

zepumph commented 11 months ago

Great thanks. Ready to close for me.

pixelzoom commented 11 months ago

👍🏻