Closed pixelzoom closed 2 years ago
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:
TANDEM_NAME_SUFFIX
resulted runtime error: Property.ts:13 Uncaught ReferenceError: Cannot access 'ReadOnlyProperty' before initialization
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.
I addressed the requests in the commits. There are still a few imperfections due to other constraints:
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?
- 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.
I reviewed the proposal with @marlitas and @pixelzoom and it sounded promising. The commits also have several TODOs pointing to this issue, some of which will need to move to side issues for help from the responsible developers.
All remaining work moved to side issues. @zepumph do you want to review this issue?
I think a quick co-review would be the fastest here.
tandemSuffix
Text/RichText should be Text
. https://github.com/phetsims/scenery/issues/1449****This blocks PhET-iO because tandem names will change for Text suffixing.
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.
renamed to tandemNameSuffix above (see https://github.com/phetsims/phet-io/issues/1855).
@samreid, anything else here?
Everything looks great, nice work and thanks. Closing.
As discovered in https://github.com/phetsims/axon/issues/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)tandem.supplied
is not checked in some places, resulting in failure with Tandem.OPT_OUTSo...
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.