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

Refactored output parameter. #115

Merged
merged 2 commits into from
Mar 7, 2022

Conversation

lewie-donckers
Copy link
Contributor

Refactored TrackingPidLocalPlanner::computeVelocityCommands() to use a return value instead of an output parameter.

The function never read from the output parameter (it was pure output and not in-/output), and the results were one of the following:

  • false and the output parameter was not set
  • true and the output parameter was set

This maps perfectly to std::optional. Either the function is successful and it returns the velocity command or it is not successful and it does not return a velocity command.

Copy link
Contributor

@Rayman Rayman left a comment

Choose a reason for hiding this comment

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

I'm not a fan of this approach, but I won't block this PR for that. I think we should definitely focus on the error handling part more in the future. std::expected or boost::checked is a good tip

@lewie-donckers lewie-donckers force-pushed the cleanup/removed-nolint branch from 791d1d4 to efcda2c Compare March 3, 2022 15:35
@lewie-donckers lewie-donckers force-pushed the cleanup/planner-refactor-output-parameter branch from 3830028 to c615c89 Compare March 3, 2022 15:36
@lewie-donckers
Copy link
Contributor Author

I'm a bit puzzled. I created what I think was a very innocuous PR which is in-line with a best practice which is widely supported within the C++ community.

Yet, for such a small change, I get quite a bit of pushback from both @Rayman and @Timple . So I was hoping you two would explain to me what you don't like about this. So I can perhaps address your concerns or refrain from these kind of changes in the future.

Is it the principle of no output parameters itself, the usage of std::optional, something else?

@Timple
Copy link
Member

Timple commented Mar 4, 2022

PR comments often sound a bit harsh as good stuff is rarely complemented 🙂 . I actually liked to learn about the std::optional.

My comment was that you are refactoring a function which doesn't describe it's actual use. But these kind of comments can simply be split-off to issues and the PR can continue: #120

@Rayman
Copy link
Contributor

Rayman commented Mar 4, 2022

So I was hoping you two would explain to me what you don't like about this.

I think we were hoping and suggesting some bigger changes to the error handling that are needed, while you made a small improvement to existing code. I sometimes use a review to comment on code that surrounds the block of code because that's the first time I'm really looking at it. I shouldn't do that and focus more on the current review.

Base automatically changed from cleanup/removed-nolint to main March 7, 2022 10:28
@lewie-donckers lewie-donckers merged commit 3173444 into main Mar 7, 2022
@lewie-donckers lewie-donckers deleted the cleanup/planner-refactor-output-parameter branch March 7, 2022 10:28
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.

3 participants