-
Notifications
You must be signed in to change notification settings - Fork 1
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
Unfamiliar TS pattern in CountingGameLevel.ts #96
Comments
@chrisklus Wanted to try out a pattern that @samreid suggested. The purpose of duplicating it is to have one that is read/write privately in the class and one that is read only publicly. While there is duplicated attributes, there is still only one Property. |
That would be good to document in the code, since it's not at all obvious what's going on. And when you're doing that, see also #97, so that the documentation is with the declaration, not the instantiation. |
It looks like this pattern is not limited to CountingGameLevel.ts. I see it in other places like Subitizer.js. So another (alternative? additional?) place that you might consider describing it is in implementation-notes.js, which often has a Patterns section. |
… Properties in CountingGameLevel.ts and Subitizer.ts. See #96.
Fixed in the commit above. Back to @chrisklus to review and close if all is good. |
While I really like the type safety of this pattern, it's not something that I've started using elsewhere in NumberPlay or other sims. I think that especially for these relatively simple cases, it's not worth the name duplication/verbosity of having a private and public Property. Perhaps Property.js will have better support to do this in the future without needing to duplicate. For now, I'm removing it to unify Game screen code with the rest of the sim. @Luisav1 thank you for doing this write up! I'll bring it back from the git history if someday it seems worth it to outfit this sim with private read/write and public readonly Properties. For now, I reverted the commit in the implementation notes. Closing. |
I brought this up in the March 3 agenda of Developer meeting, and I thought that this was the preferred strategy when you have a need to change something internally but to make it readonly publicly. I just wanted to post here noting that I will be using this in Ratio and Proportion, and that it is documented in the typescript convention document: https://github.com/phetsims/phet-info/blob/635d23558371e8b8b60bffb4bfd998d4503afb12/doc/typescript-conventions.md#access-modifiers |
An example would be nice to include with the description. |
For #84
Please explain and document why these (duplicate?) underscore fields are needed in CountingGameLevel.ts:
The text was updated successfully, but these errors were encountered: