-
Notifications
You must be signed in to change notification settings - Fork 8
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
Factor out "not disposable" assertion #436
Comments
Fine with me. |
You'll also need to update the "Memory Management" section of many implementation-notes.md files, for example https://github.com/phetsims/geometric-optics/blob/master/doc/implementation-notes.md#memory-management. |
Also note that some of the 518 occurrences of that string do not extend |
@samreid do you agree with the recommendation to use Disposable as a way to factor this out? If something doesn't extend Disposable, we could still use a factored out usage of the assertion like: /**
* @public
*/
dispose() {
// assert && assert( false, 'dispose is not supported, exists for the lifetime of the sim' );
Disposable.assertNotDisposable();
} But most cases use the option to Disposable. |
Also, if memory is an issue, we can hide this behind assert so that we don't store that boolean in production. I would be surprised if we ever noticed adding a single boolean to the base class though. |
Can you help me understand my arithmetic mistake?
It should be 192kb = 0.2MB, right? |
@samreid said:
I'm not sure who to believe, but that's debatable. For example... From https://shevchenkonik.com/blog/memory-size-of-boolean:
|
I'm not saying your arithmetic is wrong, I'm saying that it will always be in the noise, and too hard to see that change given how the browser optimizes or implementing a memory heap. |
OK factoring out sounds good to me |
It is marked for developer meeting discussion, written into the document, as stated in #436 (comment). I was going to take next steps from there.
That is very helpful. I couldn't think of what else to search for and was going to ask about it during tomorrow's discussion. I will take a look at the other cases in non pixelzoom sims.
This is stated in my previous comment about how I didn't think it was worth converting old usages. This is more a pattern that sets us up well for the future. I was not interested in (nor did I think PhET was interested in paying for) me to convert all the Disposable descendants to the better option pattern.
Sounds good to me! Thanks. |
All the sims that I'm responsible for are now using |
PSA complete. I'll take a look at the other usages of |
Searching for this |
There are 500 usages of this assertion in our project
assert && assert( false, 'dispose is not supported, exists for the lifetime of the sim' );
We now have a supertype that could write this for us. What about supporting an option to Disposable called
isDisposable: boolean
. @samreid and I were excited about the potential for factoring this nice assertion out for reuse. We ran into this question over in https://github.com/phetsims/phet-io/issues/1810@pixelzoom, how would you feel about me moving this into common code?
The text was updated successfully, but these errors were encountered: