Add guideline for defining the name of a controller#8528
Open
Conversation
There is no written standard for defining the name of a controller, and some contributors do not have a common understanding of the do's and dont's for the name. This commit adds such a guideline, highlighting the following points: - The name of a controller should be defined in a variable called `CONTROLLER_NAME` (formerly `controllerName`) - The name should be used to define custom actions and events and should be passed to `BaseController` - The name should not be exported from the package
Contributor
Author
|
Adding |
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.
Explanation
There is no written standard for defining the name of a controller, and some contributors do not have a common understanding of the do's and dont's for the name.
This commit adds such a guideline, highlighting the following points:
CONTROLLER_NAME(formerlycontrollerName)BaseControllerBesides updating the guidelines, this commit also updates the
sample-controllerspackage to follow them, most notably changingcontrollerNametoCONTROLLER_NAMEand removing theexportfrom this constant.References
Checklist
Note
Low Risk
Low risk documentation and sample-code refactor; the only potential impact is for any downstream code importing
controllerNamedirectly from sample controller source files rather than via the package’s public exports.Overview
Adds a new controller guideline recommending an internal
CONTROLLER_NAMEconstant to namespace messenger actions/events and controller state, and explicitly discouraging exporting that constant from the package.Updates the
sample-controllersexamples to follow the guideline by renamingcontrollerNametoCONTROLLER_NAME, making it non-exported, and wiring all relatedMessenger/BaseControllertype parameters andnameinitialization to the new constant.Reviewed by Cursor Bugbot for commit 85bcaf7. Bugbot is set up for automated code reviews on this repo. Configure here.