You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do **not** use contractions. They contribute to nothing but decreased readability of your code. Finding a short, descriptive name may be hard, but contraction is not an excude to not doing so.
50
+
Do **not** use contractions. They contribute to nothing but decreased readability of the code. Finding a short, descriptive name may be hard, but contraction is not an excuse for not doing so.
> **Note:**Context order affects the meaning of a method. For example, `shouldUpdateComponent` means *you* are about to update a component, while `shouldComponentUpdate` tells you that *component* will update on itself, and you are but controlling whether it should do that right now.
109
+
> **Note:**The order of context affects the meaning of a variable. For example, `shouldUpdateComponent` means *you* are about to update a component, while `shouldComponentUpdate` tells you that *component* will update on itself, and you are but controlling whether it should do that right now.
109
110
In other words, **high context emphasizes the meaning of a variable**.
110
111
111
112
---
@@ -115,6 +116,7 @@ In other words, **high context emphasizes the meaning of a variable**.
115
116
The verb part of your function name. The most important part responsible for describing what the function *does*.
116
117
117
118
### `get`
119
+
118
120
Accesses data immediately (i.e. shorthand getter of internal data).
119
121
```js
120
122
functiongetFruitsCount() {
@@ -125,6 +127,7 @@ function getFruitsCount() {
125
127
> See also [compose](#compose).
126
128
127
129
### `set`
130
+
128
131
Declaratively sets a variable with value `A` to value `B`.
129
132
130
133
```js
@@ -139,6 +142,7 @@ console.log(fruits) // 5
139
142
```
140
143
141
144
### `reset`
145
+
142
146
Sets a variable back to its initial value or state.
143
147
144
148
```js
@@ -156,6 +160,7 @@ console.log(fruits) // 5
156
160
```
157
161
158
162
### `fetch`
163
+
159
164
Requests for a data, which takes time (i.e. async request).
160
165
```js
161
166
functionfetchPosts(postCount) {
@@ -164,6 +169,7 @@ function fetchPosts(postCount) {
164
169
```
165
170
166
171
### `remove`
172
+
167
173
Removes something *from* somewhere.
168
174
169
175
For example, if you have a collection of selected filters on a search page, removing one of them from the collection is `removeFilter`, **not**`deleteFilter` (and this is how you would naturally say it in English as well):
Completely erazes something from the realms of existence.
184
191
185
192
Imagine you are a content editor, and there is that notorious post you wish to get rid of. Once you clicked a shiny "Delete post" button, the CMS performed a `deletePost` action, **not**`removePost`.
@@ -193,6 +200,7 @@ function deletePost(id) {
193
200
> See also [remove](#remove).
194
201
195
202
### `compose`
203
+
196
204
Creates a new data from the existing one. Mostly applicable to strings, objects, or functions.
197
205
198
206
```js
@@ -204,6 +212,7 @@ function composePageUrl(pageName, pageId) {
204
212
> See also [get](#get).
205
213
206
214
### `handle`
215
+
207
216
Handles an action. Often used when naming a callback method.
208
217
209
218
```js
@@ -243,6 +252,7 @@ function getRecentPosts(posts) {
243
252
Prefix enhances the meaning of a variable. It is rarely used in function names.
244
253
245
254
### `is`
255
+
246
256
Describes a characteristic or state of the current context (usually `boolean`).
247
257
248
258
```js
@@ -256,6 +266,7 @@ if (isBlue && isPresent) {
256
266
```
257
267
258
268
### `has`
269
+
259
270
Describes whether the current context possesses a certain value or state (usually `boolean`).
0 commit comments