Skip to content
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

Tandem name conventions are applied haphazardly. #267

Closed
pixelzoom opened this issue Jul 11, 2022 · 13 comments
Closed

Tandem name conventions are applied haphazardly. #267

pixelzoom opened this issue Jul 11, 2022 · 13 comments

Comments

@pixelzoom
Copy link
Contributor

As discovered in phetsims/axon#398 ...

In some cases, PhET wants to ensure that tandem names follows a specific naming convention. For example, all radio buttons should have a tandem name that ends with "RadioButton".

How those conventions are applied is implemented inconsistently, and in some cases not at all. Specifically:

  • tandem.name suffix is hardcoded in multiple places, instead of factored out (e.g. 'Property' in ReadOnlyProperty)
  • No convention is checked in places where there is a defacto standard: Checkbox, Panel, AccordionBox, Dialog, "groups", most buttons, ...
  • tandem.supplied is not checked in some places, resulting in failure with Tandem.OPT_OUT

So...

Is it desirable to add runtime checking of more tandem-name conventions? I think so. The alternative is to visually catch them in Studio, which is like looking for a needle in a haystack.

Should the implementation of those checks be similar? I think so. This will make adding additional checks easier, and make maintenance easier.

pixelzoom added a commit to phetsims/scenery that referenced this issue Jul 11, 2022
pixelzoom added a commit to phetsims/sun that referenced this issue Jul 11, 2022
@pixelzoom
Copy link
Contributor Author

pixelzoom commented Jul 11, 2022

  • tandem.name suffix is hardcoded in multiple places, instead of factored out (e.g. 'Property' in ReadOnlyProperty)

In the above commits, I factored out static TANDEM_NAME_SUFFIX where that suffix was being duplicated.

There are a few others that I identified (by searching for endsWith) but was unable to address:

  • ReadOnlyProperty duplicates suffix 'Property'. But attempting to factor that out to static TANDEM_NAME_SUFFIX resulted runtime error: Property.ts:13 Uncaught ReferenceError: Cannot access 'ReadOnlyProperty' before initialization
  • Screen duplicates suffix 'Screen'
  • RootTandem duplicates suffix 'Screen'. Making the tandem repo depend on joist (Screen) seems problematic.

@arouinfar
Copy link

Is it desirable to add runtime checking of more tandem-name conventions? I think so. The alternative is to visually catch them in Studio, which is like looking for a needle in a haystack.

I also think so. The less I need to manually review in Studio, the better.

@arouinfar arouinfar removed their assignment Jul 25, 2022
samreid added a commit to phetsims/axon that referenced this issue Aug 15, 2022
samreid added a commit to phetsims/scenery that referenced this issue Aug 15, 2022
samreid added a commit to phetsims/joist that referenced this issue Aug 15, 2022
@samreid
Copy link
Member

samreid commented Aug 15, 2022

I addressed the requests in the commits. There are still a few imperfections due to other constraints:

  • Tandem cannot import from Screen, so the constant is defined in Tandem
  • PhetioIDUtils has a duplicated block of constants that overlap with other things.

Ready for review.

UPDATE: I recalled this request:

Checkbox, Panel, AccordionBox, Dialog, "groups", most buttons, ...

Should this issue be a chip away for other occurrences too? Should we do that eagerly, or just as we are working in those areas?

@samreid samreid assigned pixelzoom and unassigned samreid Aug 15, 2022
@zepumph zepumph removed their assignment Aug 16, 2022
@pixelzoom
Copy link
Contributor Author

  • No convention is checked in places where there is a defacto standard: Checkbox, Panel, AccordionBox, Dialog, "groups", most buttons, ...

Yes, this should be discussed/addressed. Anything that has a design convention should have a corresponding check in the code to ensure that the convention is followed.

samreid added a commit to phetsims/circuit-construction-kit-common that referenced this issue Aug 26, 2022
samreid added a commit to phetsims/gravity-and-orbits that referenced this issue Aug 26, 2022
samreid added a commit to phetsims/gravity-and-orbits that referenced this issue Aug 26, 2022
@samreid
Copy link
Member

samreid commented Aug 26, 2022

All remaining work moved to side issues. @zepumph do you want to review this issue?

@zepumph
Copy link
Member

zepumph commented Sep 1, 2022

I think a quick co-review would be the fastest here.

@zepumph
Copy link
Member

zepumph commented Sep 8, 2022

@zepumph
Copy link
Member

zepumph commented Sep 8, 2022

This blocks PhET-iO because tandem names will change for Text suffixing.

@zepumph
Copy link
Member

zepumph commented Sep 8, 2022

In the next PhET-iO design meeting, we did a PSA about the new feature of PhET-iO elements called tandemSuffix. So if anyone finds a type, like Button, and not all tandem names end in "Button", we can add an assertion for that.

@zepumph
Copy link
Member

zepumph commented Sep 12, 2022

renamed to tandemNameSuffix above (see https://github.com/phetsims/phet-io/issues/1855).

  • We should most likely only assert about tandemNameSuffix when phetio validation is enabled. This seems like it will really bite the next person to try to instrument a pre-existing sim.

@zepumph
Copy link
Member

zepumph commented Sep 12, 2022

@samreid, anything else here?

@zepumph zepumph assigned samreid and unassigned zepumph Sep 12, 2022
@samreid
Copy link
Member

samreid commented Sep 13, 2022

Everything looks great, nice work and thanks. Closing.

@samreid samreid closed this as completed Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants