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

Refact removing switch case in callback class #3828

Conversation

gabrielbaldao
Copy link
Contributor

I like to avoid switch cases because of the interpreter when it reaches the low level, but I know that apparently it is not as readable, feel free to close this PR if you think this is unnecessary

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)
  • I have attached screenshots to this PR for visual changes (if needed)

@aldesantis
Copy link
Member

@gabrielbaldao I'm not entirely clear on the rationale behind this change, could you explain?

Generally speaking, I like to avoid this kind of "magic" in the code because it's harder to read and it may come back to bite us if we're not careful. However, I'm happy to consider a change if it's well motivated. 🙂

Copy link
Member

@jarednorman jarednorman left a comment

Choose a reason for hiding this comment

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

The original has two main benefits over the proposed change:

  1. The original makes it clear what the valid values are for callback_type.
  2. The original will only call the three methods it's meant to call. The new version could call any method ending in _methods erroneously.

I could imagine a refactoring to make this method clearer/simpler, but I don't think this is an improvement as it is now.

@kennyadsl
Copy link
Member

Going to close this due to a lack of response from the author. Thanks anyway!

@kennyadsl kennyadsl closed this Feb 24, 2021
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.

None yet

4 participants