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

Understanding Tandem #165

Closed
zepumph opened this issue Aug 4, 2021 · 4 comments
Closed

Understanding Tandem #165

zepumph opened this issue Aug 4, 2021 · 4 comments
Assignees

Comments

@zepumph
Copy link
Member

zepumph commented Aug 4, 2021

I see lots of places where Tandem is passed through, so I thought I would take a moment to explain why that worked its way into your sim, and what its purpose it.

Tandem is a glorified string identification tree/concatenator. It allows you to pass objects around to make ids like "screen.model.component.xProperty". It is used in its entirety for PhET-iO, and so it doesn't really need to be added to your sim at this time.

If you were going to pass the general tandem structure around (which isn't a horrible idea because it sets us up well for when this sim gets PhET-iO, then we have a more updated pattern that you can follow. Except for passing directly to the model and screenView, tandems are predominantly passed via options. Thus, I would consider the majority of tandem parameters in this sim to be out of date conventionally. I updated to the current pattern in FocalPoint.js, and changed usages just so you can be aware of this pattern. This is further outlined in https://github.com/phetsims/phet-io/blob/master/doc/phet-io-instrumentation-technical-guide.md#best-practices-for-tandem.

When this sim gets PhET-iO, this refactor will want to happen. Whether or not we do this now doesn't really matter to me.

To summarize:

  1. The current implementation of passing tandems into types is pretty much useless, and shouldn't be done unless doing a PhET-iO instrumentation (or thinking through that sort of implementation. Mostly, the action is to split tandems off as you pass them in, via tandem.createTandem( 'subComponentName' ) as opposed to passing the same instance everywhere.
  2. If you DO want to pass tandems around while doing base implementing of PhET brand, then please review the above documentation of "best practices for tandem", and use my example for focal point (which was refactored because it already supported options).
@zepumph
Copy link
Member Author

zepumph commented Aug 4, 2021

#154

@pixelzoom
Copy link
Contributor

Worth noting that I also flagged this in #179, where I noted:

Actually, the sim is quite consistent in how it passes tandem -- in all but one case (FocalPoint), it passes via a constructor parameter. This is not how I would have done it, but it's a legitimate alternative, and probably not worth changing at this point. So in the above commit, I just changed FocalPoint to match the pattern used elsewhere.

I agree that longterm, this sim should be converted to pass tandems via options, since that the preferred pattern.

@pixelzoom
Copy link
Contributor

@zepumph said:

... If you DO want to pass tandems around while doing base implementing of PhET brand, then please review the above documentation of "best practices for tandem", and use my example for focal point (which was refactored because it already supported options).

Oops. In #179, I changed FocalPoint because it was the one example that was different. I think I'll strip out the tandem constructor params in this sim, so that we can have a fresh start when this sim is eventually instrumented for PhET-iO.

@pixelzoom
Copy link
Contributor

I deleted tandem parameters in the above commit. Glad that I did, because there were so many incorrect uses of the argument that was passed in. We're now ready for a fresh start when it's time for PhET-iO instrumentation.

Closing.

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