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
function between<T>(value:T, left:T, right:T):boolean {
106
111
returnleft<=value&&value<=right;
107
112
}
108
113
```
109
114
110
-
**[⬆ back to top](#table-of-contents)**
115
+
**[⬆ 返回目录](#目录)**
111
116
112
117
### Use pronounceable variable names
113
118
119
+
### 使用可拼读的变量名称
120
+
114
121
If you can’t pronounce it, you can’t discuss it without sounding like an idiot.
115
122
116
-
**Bad:**
123
+
如果你不能把它读出来, 那你就不能和同事讨论它, 这看起来像块纱布。
124
+
125
+
**不好的:**
117
126
118
127
```ts
119
128
typeDtaRcrd102= {
@@ -123,7 +132,7 @@ type DtaRcrd102 = {
123
132
}
124
133
```
125
134
126
-
**Good:**
135
+
**好的:**
127
136
128
137
```ts
129
138
typeCustomer= {
@@ -133,51 +142,62 @@ type Customer = {
133
142
}
134
143
```
135
144
136
-
**[⬆ back to top](#table-of-contents)**
145
+
**[⬆ 返回目录](#目录)**
137
146
138
147
### Use the same vocabulary for the same type of variable
139
148
140
-
**Bad:**
149
+
### 为相同类型的变量使用相同的词汇
150
+
151
+
**不好的:**
141
152
142
153
```ts
143
154
function getUserInfo():User;
144
155
function getUserDetails():User;
145
156
function getUserData():User;
146
157
```
147
158
148
-
**Good:**
159
+
**好的:**
149
160
150
161
```ts
151
162
function getUser():User;
152
163
```
153
164
154
-
**[⬆ back to top](#table-of-contents)**
165
+
**[⬆ 返回目录](#目录)**
155
166
156
-
### Use searchable names
167
+
### 使用可搜索的名称
157
168
158
169
We will read more code than we will ever write. It's important that the code we do write is readable and searchable. By *not* naming variables that end up being meaningful for understanding our program, we hurt our readers. Make your names searchable. Tools like [TSLint](https://palantir.github.io/tslint/rules/no-magic-numbers/) can help identify unnamed constants.
0 commit comments