forked from extern/naming-cheatsheet
Update README.md
This commit is contained in:
committed by
GitHub
parent
aace01b182
commit
682744f816
14
README.md
14
README.md
@ -8,11 +8,11 @@ Naming things is hard. Is it?
|
|||||||
* **Descriptive**. Name of the variable should reflect what this variable possesses/does in the most efficient way,
|
* **Descriptive**. Name of the variable should reflect what this variable possesses/does in the most efficient way,
|
||||||
* **Intuitive**. Name of the variable should read naturally, as close to common speach as possible
|
* **Intuitive**. Name of the variable should read naturally, as close to common speach as possible
|
||||||
```js
|
```js
|
||||||
/* Bad namings */
|
/* Bad */
|
||||||
const a = 5; // "a" could mean anything
|
const a = 5; // "a" could mean anything
|
||||||
const isPaginatable = (a > 10); // "Paginatable" sounds extremely unnatural
|
const isPaginatable = (a > 10); // "Paginatable" sounds extremely unnatural
|
||||||
|
|
||||||
/* Good namings */
|
/* Good */
|
||||||
const postsCount = 5;
|
const postsCount = 5;
|
||||||
const shouldDisplayPagination = (postsCount > 10);
|
const shouldDisplayPagination = (postsCount > 10);
|
||||||
```
|
```
|
||||||
@ -26,6 +26,16 @@ class MenuItem {
|
|||||||
handleClick = (event) => { ... }
|
handleClick = (event) => { ... }
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
* Name should reflect expected result:
|
||||||
|
```js
|
||||||
|
/* Bad */
|
||||||
|
const isEnabled = this.props.enabled;
|
||||||
|
return (<Button disabled={!isEnabled} />);
|
||||||
|
|
||||||
|
/* Good */
|
||||||
|
const isDisabled = this.props.disabled;
|
||||||
|
return (<Button disabled={isDisabled} />);
|
||||||
|
```
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
### Pattern
|
### Pattern
|
||||||
|
Reference in New Issue
Block a user