-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdont-suffix-names.html
More file actions
26 lines (22 loc) · 958 Bytes
/
dont-suffix-names.html
File metadata and controls
26 lines (22 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<script src="https://rawcdn.githack.com/oscarmorrison/md-page/232e97938de9f4d79f4110f6cfd637e186b63317/md-page.js"></script><noscript>
# Don't suffix names
Don't add suffixes to variable names, especially if the suffixes are long.
```javascript
// 🔴 bad - long suffix that doesn't add value or context
// as a developer you just start to ignore most of the
// name of the variable, which defeats the purpose
const { data } = await axios(/*...*/);
const fooApiJsonResponse = data.foo;
const barApiJsonResponse = data.bar;
const bazApiJsonResponse = data.baz;
// 🟢 good - call the thing what it is
const { data } = await axios(/*...*/);
const { foo, bar, baz } = data;
// 🔴 bad - adding a suffix that just says `data` or `object`
// It's a program, we know that variables contain `data`
// so we don't need that in the name
const { data } = await axios(/*...*/);
const fooData = data.foo;
const barObject = data.bar;
const bazInfo = data.baz;
```