nep1: guidelines for getters and setters (#17645)
* nep1: guidelines for getters and setters * address a comment
This commit is contained in:
parent
13b958eb45
commit
826ad2f36f
1 changed files with 9 additions and 0 deletions
|
|
@ -301,3 +301,12 @@ Miscellaneous
|
|||
let a = """foo
|
||||
bar
|
||||
"""
|
||||
|
||||
- A getter API for a private field `foo` should preferably be named `foo`, not `getFoo`.
|
||||
A getter-like API should preferably be named `getFoo`, not `foo` if:
|
||||
* the API has side effects
|
||||
* or the cost is not `O(1)`
|
||||
For in between cases, there is no clear guideline.
|
||||
|
||||
- Likewise with a setter API, replacing `foo` with `foo=` and `getFoo` with `setFoo`
|
||||
in the above text.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue