Closed AgustinVallejo closed 5 months ago
This patch fixes this, but wanted to discuss before implementing it:
So I'm wondering what the optimal solution would be here. As I think creating an intermediate model for B-Lab, BB-Explore and BB-Compare is probably not the best option and would likely make things more complicated. Paging @samreid and @zepumph for their opinion
@samreid had some interesting words about that yesterday for me. I'm going through similar questions about subtypes in the model hierarchy for the B:B compare screen. He mentioned in PDL that there were many subclasses that fulfilled small tasks, and that it worked well in his cases.
I believe that putting this in DBModel is not ideal, and we should try to factor it out in another way. Here are some ideas:
densityExpandedProperty
. With this info, either:
Happy to discuss further, but I'd like to hear from @samreid too.
Add class BuoyancyBasicsModel extends DensityBuoyancyModel
, and has all of these:
public readonly densityExpandedProperty = new BooleanProperty( false );
public readonly percentageSubmergedExpandedProperty = new BooleanProperty( false );
public readonly poolScale: Scale;
public readonly poolScaleHeightProperty:
Then BuoyancyBasicsCompareModel extends BuoyancyBasicsModel
and BuoyancyBasicsExploreModel extends BuoyancyBasicsModel
Maybe a class or static method to create the poolScaleHeightProperty
. It will be instantiated or called twice.
For densityExpandedProperty
, is it designed to be in all the Buoyancy screens but none of the Buoyancy Basics screens? Then it would be in BuoyancyModel and not in BuoyancyBasicsModel.
But the problem is that BuoyancyLabModel also shares the property addressed in the patch. And the cause of the bug was logic from that model that wasn't replicated in the BuoyancyBasics one. So we can create a model for BuoyancyBasics, but there'll still be repeated code over in the LabModel.
This amount of duplication is OK and is preferable to (a) having poolScaleHeightProperty
where it shouldn't be or (b) mixins. Is there another recommendation? Happy to discuss in person.
class BuoyancyLabModel{
constructor(){
this.poolScaleHeightProperty = new PoolScaleHeightProperty(tandem);
}
reset(){
this.poolScaleHeightProperty.resetPoolScale();
}
}
class BuoyancyBasicsModel{
constructor(){
this.poolScaleHeightProperty = new PoolScaleHeightProperty(tandem);
}
reset(){
this.poolScaleHeightProperty.resetPoolScale();
}
}
I think having a class (PoolScaleHeightProperty
) like you have above that obscures the notifiyListenersStatic
is best.
Currently, the pool scale appears in the middle of the screen after reset. I know somebody already solved this for Buoyancy a while ago, so I'm creating the issue in case somebody knows the easy fix, otherwise, I'll look into it later.