First cut of replacement for the poorly regarded #queryCommand: "switch"#1201
Merged
Conversation
The #queryCommand: method is one of the least satisfactory elements of the original MVP design, because it results in a large and often complex and difficult to maintain switch statement (albeit a switch on value, and not type). It also doesn't lend itself to extensibility, and consequently various ad-hoc approaches have been used to achieve that, e.g. registering additional handlers in the dev tool presenter hierarchy, and the use of ClosedCommandDescriptions (commands that have their own query block, and which are invoked first, effectively shortcutting the normal chain-of-command route). This commit adds a prototypical replacement mechanism using method annotations to associate a query function with a command. The annotation is placed in the command method and specifies the selector of the query function for that command. A single query method can be associated with multiple commands. In order to test out the mechanism in practice, the #queryCommand of ClassSelector has been replaced. This is a relatively complex example, and so should cover many of the variations. A couple of extension cases have also been implemented with the new mechanism. It is, however, expected that other cases will be encountered as more #queryCommand: methods are replaced, and so the design may require refinement. All uses of the existing extension mechanism that allowed for provision of extra old-style command query methods, e.g. the queryRefactoringCommand: methods added to PackageBrowserShell, etc, have also been replaced.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #queryCommand: method is one of the least satisfactory elements of the original MVP design, because it results in a large and often complex and difficult to maintain switch statement (albeit a switch on value, and not type). It also doesn't lend itself to extensibility, and consequently various ad-hoc approaches have been used to achieve that, e.g. registering additional handlers in the dev tool presenter hierarchy, and the use of ClosedCommandDescriptions (commands that have their own query block, and
which are invoked first, effectively shortcutting the normal chain-of-command route).
This PR adds a prototypical replacement mechanism using method annotations to associate a query function with a command. The annotation is placed in the command method and specifies the selector of the query function for that command. A single query method can be associated with multiple commands.
In order to test out the mechanism in practice, the #queryCommand of ClassSelector has been replaced. This is a relatively complex example, and so should cover many of the variations. A couple of extension cases have also been implemented with the new mechanism. It is, however, expected that other cases will be encountered as more #queryCommand: methods are replaced, and so the design may require refinement.
All uses of the existing extension mechanism that allowed for provision of extra old-style command query methods, e.g. the queryRefactoringCommand: methods added to PackageBrowserShell, etc, have also been replaced.