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

Code cleanup from #12551 #13694

Merged
merged 1 commit into from
Dec 12, 2019
Merged

Conversation

AmeliaEScott
Copy link
Contributor

Describe problem solved by this pull request
#12551 was merged before I could address the review of @bkueng

Describe your solution
I addressed the review of @bkueng

Describe possible alternatives
I could ignore the review of @bkueng . But he seems to know a lot more than me about writing good code, so ignoring him would be unwise.

@AmeliaEScott
Copy link
Contributor Author

AmeliaEScott commented Dec 6, 2019

@bkueng regarding this review: #12551 (comment)
The reason I kept it as a default parameter is because in most of the places this library was used before my changes, the default constructor (with no arguments) was being used. I would like to keep this as it is, so there are fewer changes to make elsewhere.

An alternative solution would be to have two constructors:

Battery() : Battery(1, nullptr) {}
Battery(int i, ModuleParams *parent) {...}

But I guess that's functionally identical to the version with optional parameters.

@bkueng
Copy link
Member

bkueng commented Dec 9, 2019

Thanks Timmy :)
The reason I asked for the change is for users of the class to be forced to set parent. If they are not, it can easily be forgotten, and then dynamic parameter updates won't work.
Can you update AnalogBattery as well?

@julianoes julianoes merged commit 11bbc8a into PX4:master Dec 12, 2019
@AmeliaEScott AmeliaEScott deleted the pr-multibattery-2 branch December 12, 2019 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants