Skip to content

Commit 88effdb

Browse files
committed
Update CODING_STANDARDS.md
Expand with more points
1 parent d8c27eb commit 88effdb

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

CODING_STANDARDS.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,21 @@ API docs.
169169

170170

171171
#### Getters and Setters
172+
* Avoid long or complex getters and setters. If the logic of an accessor would take more than
173+
three lines, introduce a new method to contain the logic.
174+
* A getter should immediately precede its corresponding setter.
175+
* Decorators such as `@Input` should be applied to the getter and not the setter.
172176
* Always use a `readonly` property instead of a getter (with no setter) when possible.
173-
* Avoid long getters and setters. If the logic of an accessor would take more than three lines,
174-
introduce a new method to contain the logic.
177+
```ts
178+
/** YES */
179+
readonly active: boolean;
180+
181+
/** NO */
182+
get active(): boolean {
183+
// Using a getter solely to make the property read-only.
184+
return this._active;
185+
}
186+
```
175187

176188
#### JsDoc comments
177189

0 commit comments

Comments
 (0)