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

Use a consistent ordering for App and Window APIs. #2403

Merged
merged 6 commits into from
Feb 20, 2024

Conversation

freakboy3742
Copy link
Member

The App and Window classes are quite large; as a result, they can be hard to navigate, and several recent additions have added methods in places that don't make a lot of sense in terms of the overall ordering of methods in those classes.

In order to aid long-term maintenance, this PR re-orders the definition of methods in the App and Window classes, and adds signpost comments to help break up a 1000 line class into more manageable chunks that are grouped by purpose.

Inside each chunk, methods are orders alphabetically; the only exception to this ordering are "utility" methods, all of which are prefixed with an underscore, and occur just before the method in which they are used.

There are no functionality changes in this PR. Other than re-ordering methods and adding docstrings, the only other changes are a couple of method renames (to make underscore usage consistent), and the extraction of the Winforms exception handling into top-level module methods, rather than being features of the App class.

In theory, a similar set of reorganisations could be applied to other modules; however, the problem seems a lot less acute for widgets and other utilities as there is (generally speaking) a lot less code to navigate. App and Window are the "big" classes.

This is essentially extracted from the work in #2244 - refactoring the app class, involved making sense of the methods that are there, which is made more difficult by the current, slightly ad-hoc ordering. Merging this PR should hopefully make that PR easier to review.

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@mhsmith mhsmith merged commit ae2e38d into beeware:main Feb 20, 2024
35 checks passed
@freakboy3742 freakboy3742 deleted the consistent-ordering branch February 20, 2024 22:17
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.

2 participants