-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy path1-bad-names.js
55 lines (48 loc) · 947 Bytes
/
1-bad-names.js
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'use strict';
// Antipattern: Short identifiers
{
const n = 'Marcus Aurelius';
}
// Antipattern: Long identifiers
{
const romanEmperorAndOutstandingThinker = 'Marcus Aurelius';
}
// Antipattern: Same name but different meaning
{
const name = 'Marcus Aurelius';
if (name) {
const name = './config.js';
console.dir({ name });
}
}
// Antipattern: Same meaning but different naming
{
const fileName = './config.js';
if (!fileName) {
const file = './backup/config.js';
if (!file) {
const filePath = '../config.js';
console.dir({ filePath });
}
}
}
// Antipattern: Inconsistent names
{
const api = {
setPort: () => {},
assignAddress: () => {},
definePath: () => {},
};
console.dir({ api });
}
// Antipattern: Non descriptive names
{
class ApplicationController {
constructor(link) {
this.link = link;
}
execute(handler) {
this.link(handler);
}
}
}