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

feat: create createBackingVariable method #2106

Merged
merged 6 commits into from
Jan 4, 2024

Conversation

shivalipatel6
Copy link
Contributor

@shivalipatel6 shivalipatel6 commented Dec 12, 2023

Created a protected method that creates the variable for observable_parameter_model to make the class easier to subclass

The basics

The details

Resolves

Fixes #1861

Proposed Changes

Creates a new method in the ObservableParameterModel class that will be used to create new variables instead of using the constructor.

Reason for Changes

Makes the class easier to subclass when a developer wants to create a typed variable.

Test Coverage

I ran the test class in the block-shareable-procedure files and it ran.
createBackingVariableTest

Documentation

Additional Information

Created a protected method that creates the variable for observable_parameter_model to make the class easier to subclass
@shivalipatel6 shivalipatel6 requested a review from a team as a code owner December 12, 2023 23:05
@shivalipatel6 shivalipatel6 requested review from NeilFraser and removed request for a team December 12, 2023 23:05
@BeksOmega BeksOmega self-requested a review December 15, 2023 22:54
@BeksOmega BeksOmega self-assigned this Dec 15, 2023
@BeksOmega BeksOmega removed the request for review from NeilFraser December 15, 2023 22:54
@BeksOmega
Copy link
Contributor

@shivalipatel6 I think this looks great! Can you call the protected function from the constructor? I think if you do that it's no longer a breaking change.

This will change my last commit from a breaking change to a non-breaking change.
ran npm ci and npm run format to find my formatting errors and fix them
* @returns This parameter model.
*/

protected createBackingVariable(name: string, varId?: string): this {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I should have asked for this change in my last review :/

Could you actually change this to return the new variable instead of assigning it? Then you can assign it in the constructor. That way all of the side effects are localized to the constructor, and people overriding this function don't have to remember to do the side effect!

Then this should be good to go =)

changed the return type of createBackingVariable so that it returns the variable itself.
ran npm ci and npm run format to address formatting errors in the pr
@shivalipatel6 shivalipatel6 changed the title feat!: create createBackingVariable method feat: create createBackingVariable method Dec 20, 2023
Copy link
Contributor

@BeksOmega BeksOmega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two nits then should be good to go!

@BeksOmega
Copy link
Contributor

This looks great! Thank you so much @shivalipatel6 =)

@BeksOmega BeksOmega merged commit 1d0df1e into google:master Jan 4, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make it easier to subclass ObservableParameterModel
3 participants