Skip to content

Commit 09459b8

Browse files
author
Admin
committed
Variables translate
1 parent 92f14ff commit 09459b8

File tree

1 file changed

+53
-49
lines changed

1 file changed

+53
-49
lines changed

README.md

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
## Содержание
1010

11-
1. [Введение](#introduction)
11+
1. [Введение](#введение)
1212
2. [Переменные](#variables)
1313
3. [Функции](#functions)
1414
4. [Объекты и структуры данных](#objects-and-data-structures)
@@ -45,15 +45,15 @@ you shout when reading code](https://www.osnews.com/images/comics/wtfm.jpg)
4545
черновик, как мокрый кусок глины который только постеменно приобретает свою форму. Не упрекайте себя при
4646
первых набросках кода, которые нуждаются в улучшении. Улучшайте код вместо этого!
4747

48-
**[⬆ Вернуться в начало](#table-of-contents)**
48+
**[⬆ Вернуться в начало](#содержание)**
4949

50-
## Variables
50+
## Переменные
5151

52-
### Use meaningful variable names
52+
### Используйте выразительные имена переменных
5353

54-
Distinguish names in such a way that the reader knows what the differences offer.
54+
Различайте имена таким образом, чтобы читатель знал что они означают.
5555

56-
**Bad:**
56+
**Плохо:**
5757

5858
```ts
5959
function between<T>(a1: T, a2: T, a3: T): boolean {
@@ -62,21 +62,21 @@ function between<T>(a1: T, a2: T, a3: T): boolean {
6262

6363
```
6464

65-
**Good:**
65+
**Хорошо:**
6666

6767
```ts
6868
function between<T>(value: T, left: T, right: T): boolean {
6969
return left <= value && value <= right;
7070
}
7171
```
7272

73-
**[⬆ back to top](#table-of-contents)**
73+
**[⬆ back to top](#содержание)**
7474

75-
### Use pronounceable variable names
75+
### Используйте произносительные имена переменных
7676

77-
If you can’t pronounce it, you can’t discuss it without sounding like an idiot.
77+
Если вы не можете произносить их, вы не можете обсуждать их не выглядя как идиот.
7878

79-
**Bad:**
79+
**Плохо:**
8080

8181
```ts
8282
type DtaRcrd102 = {
@@ -86,7 +86,7 @@ type DtaRcrd102 = {
8686
}
8787
```
8888
89-
**Good:**
89+
**Хорошо:**
9090
9191
```ts
9292
type Customer = {
@@ -96,38 +96,42 @@ type Customer = {
9696
}
9797
```
9898
99-
**[⬆ back to top](#table-of-contents)**
99+
**[⬆ back to top](#содержание)**
100100
101-
### Use the same vocabulary for the same type of variable
101+
### Используйте один и тот же словарь для одних и тех же типов переменных
102102
103-
**Bad:**
103+
**Плохо:**
104104
105105
```ts
106106
function getUserInfo(): User;
107107
function getUserDetails(): User;
108108
function getUserData(): User;
109109
```
110110

111-
**Good:**
111+
**Хорошо:**
112112

113113
```ts
114114
function getUser(): User;
115115
```
116116

117-
**[⬆ back to top](#table-of-contents)**
117+
**[⬆ back to top](#содержание)**
118118

119-
### Use searchable names
119+
### Используйте имена, доступные для поиска
120120

121-
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.
121+
Мы читаем больще кода, чем пишем. Это важно чтобы код, который мы пишем, был читаемым и достумным для поиска.
122+
Не называйте переменные, которые в конечном итое имеют смысл только для наших программ мы вредим нашим читателям.
123+
Делайте ваши имена доступными для поиска.
124+
Такие инструменты, как [TSLint](https://palantir.github.io/tslint/rules/no-magic-numbers/) и [ESLint](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-magic-numbers.md)
125+
могут помочь идентифицировать не названные константы.
122126

123-
**Bad:**
127+
**Плохо:**
124128

125129
```ts
126130
// What the heck is 86400000 for?
127131
setTimeout(restart, 86400000);
128132
```
129133

130-
**Good:**
134+
**Хорошо:**
131135

132136
```ts
133137
// Declare them as capitalized named constants.
@@ -136,11 +140,11 @@ const MILLISECONDS_IN_A_DAY = 24 * 60 * 60 * 1000;
136140
setTimeout(restart, MILLISECONDS_IN_A_DAY);
137141
```
138142

139-
**[⬆ back to top](#table-of-contents)**
143+
**[⬆ back to top](#содержание)**
140144

141-
### Use explanatory variables
145+
### Используйте объясняющие переменные
142146

143-
**Bad:**
147+
**Плохо:**
144148

145149
```ts
146150
declare const users: Map<string, User>;
@@ -150,7 +154,7 @@ for (const keyValue of users) {
150154
}
151155
```
152156

153-
**Good:**
157+
**Хорошо:**
154158

155159
```ts
156160
declare const users: Map<string, User>;
@@ -160,36 +164,36 @@ for (const [id, user] of users) {
160164
}
161165
```
162166

163-
**[⬆ back to top](#table-of-contents)**
167+
**[⬆ back to top](#содержание)**
164168

165-
### Avoid Mental Mapping
169+
### Избегайте ментальных связей
166170

167-
Explicit is better than implicit.
168-
*Clarity is king.*
171+
Явное лучше, чем неявное.
172+
*Ясность - это король.*
169173

170-
**Bad:**
174+
**Плохо:**
171175

172176
```ts
173177
const u = getUser();
174178
const s = getSubscription();
175179
const t = charge(u, s);
176180
```
177181

178-
**Good:**
182+
**Хорошо:**
179183

180184
```ts
181185
const user = getUser();
182186
const subscription = getSubscription();
183187
const transaction = charge(user, subscription);
184188
```
185189

186-
**[⬆ back to top](#table-of-contents)**
190+
**[⬆ back to top](#содержание)**
187191

188-
### Don't add unneeded context
192+
### Не добавляйте не нужный контекст
189193

190-
If your class/type/object name tells you something, don't repeat that in your variable name.
194+
Если имя вашего класса/типа/объекта говорит само за себя, не повторяйте его в вашем именни переменной.
191195

192-
**Bad:**
196+
**Плохо:**
193197

194198
```ts
195199
type Car = {
@@ -203,7 +207,7 @@ function print(car: Car): void {
203207
}
204208
```
205209

206-
**Good:**
210+
**Хорошо:**
207211

208212
```ts
209213
type Car = {
@@ -217,13 +221,13 @@ function print(car: Car): void {
217221
}
218222
```
219223

220-
**[⬆ back to top](#table-of-contents)**
224+
**[⬆ back to top](#содержание)**
221225

222-
### Use default arguments instead of short circuiting or conditionals
226+
### Используйте аргументы по умолчанию вместо замыканий или вычислений
223227

224-
Default arguments are often cleaner than short circuiting.
228+
Аргументы по умолчанию часто чище, чем короткое вычисление.
225229

226-
**Bad:**
230+
**Плохо:**
227231

228232
```ts
229233
function loadPages(count?: number) {
@@ -232,22 +236,22 @@ function loadPages(count?: number) {
232236
}
233237
```
234238

235-
**Good:**
239+
**Хорошо:**
236240

237241
```ts
238242
function loadPages(count: number = 10) {
239243
// ...
240244
}
241245
```
242246

243-
**[⬆ back to top](#table-of-contents)**
247+
**[⬆ back to top](#содержание)**
244248

245-
### Use enum to document the intent
249+
### Используйте enum дл документирования
246250

247-
Enums can help you document the intent of the code. For example when we are concerned about values being
248-
different rather than the exact value of those.
251+
Enam'ы могут помочь документированию вашего кода. Например когда мы обеспокоены, что наши переменные
252+
отличаются от значений.
249253

250-
**Bad:**
254+
**Плохо:**
251255

252256
```ts
253257
const GENRE = {
@@ -270,7 +274,7 @@ class Projector {
270274
}
271275
```
272276

273-
**Good:**
277+
**Хорошо:**
274278

275279
```ts
276280
enum GENRE {
@@ -293,9 +297,9 @@ class Projector {
293297
}
294298
```
295299

296-
**[⬆ back to top](#table-of-contents)**
300+
**[⬆ back to top](#содержание)**
297301

298-
## Functions
302+
## Функции
299303

300304
### Function arguments (2 or fewer ideally)
301305

0 commit comments

Comments
 (0)