Use a consistent ordering for App and Window APIs. #2403
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: