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 and class names for the phMeterNodes #238

Closed
samreid opened this issue Aug 26, 2022 · 7 comments
Closed

Tandem and class names for the phMeterNodes #238

samreid opened this issue Aug 26, 2022 · 7 comments

Comments

@samreid
Copy link
Member

samreid commented Aug 26, 2022

phetsims/tandem#267 revealed that some of the phMeterNodes are actually AccordionBox instances, but they are not named as such. Based on phetsims/tandem#267, I renamed the tandems, but did not want to rename the implementation classes until we confirm the desired behavior. @arouinfar can you please check the tandems and recommend:

  • is pHMeterNodeAccordionBox an OK tandem?
  • if not, what should it be?
@arouinfar
Copy link
Contributor

@samreid pHMeterNodeAccordionBox seems reasonable. I thought about shortening it to pHMeterAccordionBox, but the first screen contains a pHMeterNode, so I think pHMeterNodeAccordionBox is more consistent.

I already see pHMeterNodeAccordionBox in master, and it looks good. Not sure if there is anything else for this issue, so back to @samreid.

@arouinfar arouinfar assigned samreid and unassigned arouinfar Aug 26, 2022
samreid added a commit that referenced this issue Aug 26, 2022
samreid added a commit that referenced this issue Aug 26, 2022
@samreid
Copy link
Member Author

samreid commented Aug 26, 2022

Thanks, I renamed the file accordingly. Closing.

@samreid samreid closed this as completed Aug 26, 2022
@pixelzoom
Copy link
Contributor

pHMeterNodeAccordionBox is a little weird. But @arouinfar makes reasonable arguments, so I can certainly live with it.

I could also have lived with both of them being named pHMeterNode, because even the one that is an AccordionBox is logically a "pH Meter". And I think it's fine for there to be exceptions to the tandem suffix conventions when it makes sense.

@pixelzoom
Copy link
Contributor

I will also note that anyone searching for pHMeterAccordionBox, which I did initially, is not going to find it.

@pixelzoom
Copy link
Contributor

Since class name PHMeterNodeAccordionBox is sufficiently weird/redundant to cause someone (including my future self) to pause... I've added this documentaton to PHMeterNodeAccordionBox.js in the above commit:

 * NOTE: This class has the somewhat-redundant name PHMeterNodeAccordionBox because we have 2 pH meters in this
 * sim (see MacroPHMeterNode for the Macro screen), and we want them both to be discoverable in Studio by searching
 * for 'pHMeterNode'. So their tandem names are 'pHMeterNodeAccordionBox' and 'pHMeterNode'. The downside of this is
 * that someone who is familiar with tandem naming conventions will not find 'pHMeterAccordionBox'.
 * See https://github.com/phetsims/ph-scale/issues/238.

@pixelzoom
Copy link
Contributor

pixelzoom commented Sep 6, 2022

Reopening.

As I said above:

Since class name PHMeterNodeAccordionBox is sufficiently weird/redundant to cause someone (including my future self) to pause...

This immediately came up in #242 (convert to TypeScript). After some head scratching, and cursing myself for allowing PHMeterNodeAccordionBox to be named as such...

Micro pH Meter does not allow changing pH; My Solutions pH meter does. To resolve TypeScript errors, I had to refactor PHMeterNodeAccordionBox into subclasses. And since we typically name an AccordionBox subclass using the pattern {{TITLE}}AccordionBox, it made sense to change the class names as follows:

PHAccordionBox (base class, whose title is 'pH')
  MicroPHAccordionBox (subclass for Micro screen)
  MySolutionPHAccordionBox (subclass for My Solutions screen)

It then made sense to change the tandem names to match. So the tandem names for the 3 screens are now as follows (Macro is unchanged):

phScale.macroScreen.view.pHMeterNode
phScale.microSolutionScreen.view.pHAccordionBox
phScale.mySolutionScreen.view.pHAccordionBox

In this case I feel strongly that clarity of code, and sticking to naming conventions, is more important than the Studio client being able to search for "pHMeterNode" and find all 3 meters. Hopefully that's OK with @arouinfar, back to her for review.

@arouinfar
Copy link
Contributor

In this case I feel strongly that clarity of code, and sticking to naming conventions, is more important than the Studio client being able to search for "pHMeterNode" and find all 3 meters.

I completely agree. I think pHAccordionBox is conventional and human-readable, so I don't have any worries about clients interpreting the tandem name. It's also easily discoverable in the tree using the select feature in Studio.

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

3 participants