Add guideline for defining the name of a controller#8528
Merged
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 |
Mrtenz
reviewed
Apr 21, 2026
|
|
||
| Every controller has a name, which is not only used to namespace the controller's messenger actions and events, but also to namespace the controller's state data when composed with other controllers. | ||
|
|
||
| The name should be defined in a constant called `CONTROLLER_NAME` so that it can be easily changed if the need arises. (This variable was formerly called `controllerName`.) The name should be used to initialize the messenger, and should also be passed to the `BaseController` constructor. |
Member
There was a problem hiding this comment.
Probably not necessary to include this.
Suggested change
| The name should be defined in a constant called `CONTROLLER_NAME` so that it can be easily changed if the need arises. (This variable was formerly called `controllerName`.) The name should be used to initialize the messenger, and should also be passed to the `BaseController` constructor. | |
| The name should be defined in a constant called `CONTROLLER_NAME` so that it can be easily changed if the need arises. The name should be used to initialize the messenger, and should also be passed to the `BaseController` constructor. |
Mrtenz
reviewed
Apr 21, 2026
|
|
||
| const CONTROLLER_NAME = 'FooController'; | ||
|
|
||
| export type FooControllerSomeCustomAction = { |
Member
There was a problem hiding this comment.
This example doesn't really make sense given the MESSENGER_EXPOSED_METHODS pattern. Maybe update it to use ControllerGetStateAction or some events?
Contributor
Author
There was a problem hiding this comment.
Yeah, you're right. In fact most of the examples in this document don't make much sense anymore 😅 I will update this.
Contributor
Author
There was a problem hiding this comment.
Okay, I've updated these examples here: b450e6d. I replaced FooController with a more realistic name and I used events instead of actions for the examples.
Mrtenz
approved these changes
Apr 23, 2026
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
Medium Risk
Removes an exported constant and renames
controllerNametoCONTROLLER_NAMEin sample controllers, which could break any consumers importing that symbol even though runtime behavior is unchanged.Overview
Adds a new controller guideline requiring a single internal
CONTROLLER_NAMEconstant to namespace messenger actions/events andBaseControllerstate, and explicitly discouraging exporting that constant from the package.Updates the
sample-controllersexamples (sample-gas-prices-controllerandsample-petnames-controller) to follow the guideline by replacing exportedcontrollerNamewith an internalCONTROLLER_NAMEand wiring all messenger/type andBaseControllerreferences to it.Reviewed by Cursor Bugbot for commit 4757fdb. Bugbot is set up for automated code reviews on this repo. Configure here.