-
Notifications
You must be signed in to change notification settings - Fork 6.8k
chore: add guidance on getters/setters to coding standards #7977
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about Input
should always be on setter?
Setters should come before getters?
@amcdnl added |
CODING_STANDARDS.md
Outdated
@@ -167,6 +167,14 @@ be part of the user-facing API. This typically applies to symbols used in templa | |||
Additionally, the `@docs-private` JsDoc annotation can be used to hide any symbol from the public | |||
API docs. | |||
|
|||
|
|||
#### Getters and Setters | |||
* Always use a `readonly` property instead of a getter (with no setter) when possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you give an example? My brain is struggling to parse the use case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
CODING_STANDARDS.md
Outdated
* Always use a `readonly` property instead of a getter (with no setter) when possible. | ||
* Avoid long getters and setters. If the logic of an accessor would take more than three lines, | ||
introduce a new method to contain the logic. | ||
* A getter should also immediately precede its corresponding setter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove "also"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
CODING_STANDARDS.md
Outdated
* Always use a `readonly` property instead of a getter (with no setter) when possible. | ||
* Avoid long getters and setters. If the logic of an accessor would take more than three lines, | ||
introduce a new method to contain the logic. | ||
* A getter should also immediately precede its corresponding setter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If @Input
is on setter, it should come first right? This is saying that getters precede the setter (getters come first)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getters come first, @input
always goes on the getter.
d1f265d
to
88effdb
Compare
Expand with more points
88effdb
to
826ffb2
Compare
@amcdnl @andrewseguin poke for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
No description provided.