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

Refactor _option_list.py to consistently use accessors #2986

Closed
BenMarkFrost opened this issue Jul 22, 2023 · 5 comments
Closed

Refactor _option_list.py to consistently use accessors #2986

BenMarkFrost opened this issue Jul 22, 2023 · 5 comments

Comments

@BenMarkFrost
Copy link

BenMarkFrost commented Jul 22, 2023

As noticed in #2985, the _options_list.py file can be organised better to consistently use accessor functions such as get_option_by_index() instead of directly accessing _options.

I'm happy to implement this if it's the direction we want to go in? @rodrigogiraoserrao

@Textualize Textualize deleted a comment from github-actions bot Jul 22, 2023
@davep
Copy link
Contributor

davep commented Jul 22, 2023

Not sure if it's relevant here or not, but it's worth keeping in mind that all other things being equal, we tend to go with the most direct route to a value to keep the code as efficient as possible.

@rodrigogiraoserrao
Copy link
Contributor

That's a fair point @davep.
Now, I'm left wondering why we have the get_option_by_index, then.
Is it just for public consumption, and internally we go straight to _options?

@davep
Copy link
Contributor

davep commented Jul 22, 2023

Now, I'm left wondering why we have the get_option_by_index, then.

Yes, that's part of the public interface.

To be clear though: I'm not setting a hard rule here, just dropping in a driveby reminder that normally our PRs will get a review along the line of "fewer calls please". Personally I'm a fan of building abstraction on abstraction but I see the value in keeping it as streamlined as possible internally (mostly if it's something that's likely to be called often).

@willmcgugan
Copy link
Collaborator

I don't think this is needed. It's fine for methods to use internal symbols.

Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

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

No branches or pull requests

4 participants