Skip to content

Commit 727ec77

Browse files
author
Marc Brüderlin
committed
Update to latest revision
1 parent f90ebe1 commit 727ec77

File tree

1 file changed

+61
-63
lines changed

1 file changed

+61
-63
lines changed

README.md

+61-63
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ saveCityZipCode(city, zipCode);
113113
**[⬆ nach oben](#table-of-contents)**
114114

115115
### Vermeide Mental Mapping
116-
Explizites ist besser als Im­pli­zites.
116+
Explizites ist besser als Implizites.
117117

118118
**Schlecht:**
119119
```javascript
@@ -266,13 +266,13 @@ function emailClients(clients) {
266266

267267
**Gut:**
268268
```javascript
269-
function emailClients(clients) {
269+
function emailActiveClients(clients) {
270270
clients
271-
.filter(isClientActive)
271+
.filter(isActiveClient)
272272
.forEach(email);
273273
}
274274

275-
function isClientActive(client) {
275+
function isActiveClient(client) {
276276
const clientRecord = database.lookup(client);
277277
return clientRecord.isActive();
278278
}
@@ -289,7 +289,7 @@ function addToDate(date, month) {
289289

290290
const date = new Date();
291291

292-
// Es ist schwierig zu sagen was hinzugefügt wird
292+
// Es ist schwierig zu sagen was laut Funktionsnamen hinzugefügt wird
293293
addToDate(date, 1);
294294
```
295295

@@ -434,18 +434,20 @@ function showEmployeeList(employees) {
434434
const expectedSalary = employee.calculateExpectedSalary();
435435
const experience = employee.getExperience();
436436

437-
let portfolio = employee.getGithubLink();
438-
439-
if (employee.type === 'manager') {
440-
portfolio = employee.getMBAProjects();
441-
}
442-
443437
const data = {
444438
expectedSalary,
445-
experience,
446-
portfolio
439+
experience
447440
};
448441

442+
switch (employee.type) {
443+
case 'manager':
444+
data.portfolio = employee.getMBAProjects();
445+
break;
446+
case 'developer':
447+
data.githubLink = employee.getGithubLink();
448+
break;
449+
}
450+
449451
render(data);
450452
});
451453
}
@@ -467,7 +469,7 @@ function createMenu(config) {
467469
config.title = config.title || 'Foo';
468470
config.body = config.body || 'Bar';
469471
config.buttonText = config.buttonText || 'Baz';
470-
config.cancellable = config.cancellable === undefined ? config.cancellable : true;
472+
config.cancellable = config.cancellable !== undefined ? config.cancellable : true;
471473
}
472474

473475
createMenu(menuConfig);
@@ -612,7 +614,7 @@ const addItemToCart = (cart, item) => {
612614
**Gut:**
613615
```javascript
614616
const addItemToCart = (cart, item) => {
615-
return [...cart, { item, date : Date.now() }];
617+
return [...cart, { item, date: Date.now() }];
616618
};
617619
```
618620

@@ -697,11 +699,9 @@ const programmerOutput = [
697699
}
698700
];
699701

700-
const INITIAL_VALUE = 0;
701-
702702
const totalOutput = programmerOutput
703-
.map((programmer) => programmer.linesOfCode)
704-
.reduce((acc, linesOfCode) => acc + linesOfCode, INITIAL_VALUE);
703+
.map(output => output.linesOfCode)
704+
.reduce((totalLines, lines) => totalLines + lines);
705705
```
706706
**[⬆ nach oben](#table-of-contents)**
707707

@@ -959,7 +959,7 @@ function makeBankAccount() {
959959

960960
// Ein "Setter", wird duch das unten zurückgegebene Objekt public gemacht
961961
function setBalance(amount) {
962-
// ... validieren, bevor der Kontostand aktualisiert wird
962+
// ... validieren bevor der Kontostand aktualisiert wird
963963
balance = amount;
964964
}
965965

@@ -1098,10 +1098,10 @@ einfach `this` zurück und du wirst weitere Methoden verketten können.
10981098
**Schlecht:**
10991099
```javascript
11001100
class Car {
1101-
constructor() {
1102-
this.make = 'Honda';
1103-
this.model = 'Accord';
1104-
this.color = 'white';
1101+
constructor(make, model, color) {
1102+
this.make = make;
1103+
this.model = model;
1104+
this.color = color;
11051105
}
11061106

11071107
setMake(make) {
@@ -1121,51 +1121,47 @@ class Car {
11211121
}
11221122
}
11231123

1124-
const car = new Car();
1124+
const car = new Car('Ford','F-150','red');
11251125
car.setColor('pink');
1126-
car.setMake('Ford');
1127-
car.setModel('F-150');
11281126
car.save();
11291127
```
11301128

11311129
**Gut:**
11321130
```javascript
11331131
class Car {
1134-
constructor() {
1135-
this.make = 'Honda';
1136-
this.model = 'Accord';
1137-
this.color = 'white';
1132+
constructor(make, model, color) {
1133+
this.make = make;
1134+
this.model = model;
1135+
this.color = color;
11381136
}
11391137

11401138
setMake(make) {
11411139
this.make = make;
1142-
// Anmerkung: Gebe this für die Verkettung zurück
1140+
// Anmerkung: Gebe this für die Verkettung zurück
11431141
return this;
11441142
}
11451143

11461144
setModel(model) {
11471145
this.model = model;
1148-
// Anmerkung: Gebe this für die Verkettung zurück
1146+
// Anmerkung: Gebe this für die Verkettung zurück
11491147
return this;
11501148
}
11511149

11521150
setColor(color) {
11531151
this.color = color;
1154-
// Anmerkung: Gebe this für die Verkettung zurück
1152+
// Anmerkung: Gebe this für die Verkettung zurück
11551153
return this;
11561154
}
11571155

11581156
save() {
11591157
console.log(this.make, this.model, this.color);
1160-
// Anmerkung: Gebe this für die Verkettung zurück
1158+
// Anmerkung: Gebe this für die Verkettung zurück
11611159
return this;
11621160
}
11631161
}
11641162

1165-
const car = new Car()
1163+
const car = new Car('Ford','F-150','red')
11661164
.setColor('pink')
1167-
.setMake('Ford')
1168-
.setModel('F-150')
11691165
.save();
11701166
```
11711167
**[⬆ nach oben](#table-of-contents)**
@@ -1277,7 +1273,6 @@ class UserAuth {
12771273
}
12781274
}
12791275

1280-
12811276
class UserSettings {
12821277
constructor(user) {
12831278
this.user = user;
@@ -1686,7 +1681,7 @@ du die Abdeckungsziele erreichst bevor ein Feature veröffentlicht oder vorhande
16861681

16871682
**Schlecht:**
16881683
```javascript
1689-
const assert = require('assert');
1684+
import assert from 'assert';
16901685

16911686
describe('MakeMomentJSGreatAgain', () => {
16921687
it('handles date boundaries', () => {
@@ -1709,7 +1704,7 @@ describe('MakeMomentJSGreatAgain', () => {
17091704

17101705
**Gut:**
17111706
```javascript
1712-
const assert = require('assert');
1707+
import assert from 'assert';
17131708

17141709
describe('MakeMomentJSGreatAgain', () => {
17151710
it('handles 30-day months', () => {
@@ -1863,29 +1858,29 @@ ignorieren solltest.
18631858
**Schlecht:**
18641859
```javascript
18651860
getdata()
1866-
.then((data) => {
1867-
functionThatMightThrow(data);
1868-
})
1869-
.catch((error) => {
1870-
console.log(error);
1871-
});
1861+
.then((data) => {
1862+
functionThatMightThrow(data);
1863+
})
1864+
.catch((error) => {
1865+
console.log(error);
1866+
});
18721867
```
18731868

18741869
**Gut:**
18751870
```javascript
18761871
getdata()
1877-
.then((data) => {
1878-
functionThatMightThrow(data);
1879-
})
1880-
.catch((error) => {
1881-
// Eine Option (Erweckt mehr Aufmerksamkeit als console.log):
1882-
console.error(error);
1883-
// Eine andere Möglichkeit:
1884-
notifyUserOfError(error);
1885-
// Eine andere Möglichkeit:
1886-
reportErrorToService(error);
1887-
// ODER wende alle drei an!
1888-
});
1872+
.then((data) => {
1873+
functionThatMightThrow(data);
1874+
})
1875+
.catch((error) => {
1876+
// Eine Option (Erweckt mehr Aufmerksamkeit als console.log):
1877+
console.error(error);
1878+
// Eine andere Möglichkeit:
1879+
notifyUserOfError(error);
1880+
// Eine andere Möglichkeit:
1881+
reportErrorToService(error);
1882+
// ODER wende alle drei an!
1883+
});
18891884
```
18901885
**[⬆ nach oben](#table-of-contents)**
18911886

@@ -1925,8 +1920,8 @@ class Alpaca {}
19251920
const DAYS_IN_WEEK = 7;
19261921
const DAYS_IN_MONTH = 30;
19271922

1928-
const songs = ['Back In Black', 'Stairway to Heaven', 'Hey Jude'];
1929-
const artists = ['ACDC', 'Led Zeppelin', 'The Beatles'];
1923+
const SONGS = ['Back In Black', 'Stairway to Heaven', 'Hey Jude'];
1924+
const ARTISTS = ['ACDC', 'Led Zeppelin', 'The Beatles'];
19301925

19311926
function eraseDatabase() {}
19321927
function restoreDatabase() {}
@@ -1979,7 +1974,7 @@ class PerformanceReview {
19791974
}
19801975
}
19811976

1982-
const review = new PerformanceReview(user);
1977+
const review = new PerformanceReview(employee);
19831978
review.perfReview();
19841979
```
19851980

@@ -2060,7 +2055,7 @@ function hashIt(data) {
20602055
const char = data.charCodeAt(i);
20612056
hash = ((hash << 5) - hash) + char;
20622057

2063-
// Convert to 32-bit integer
2058+
// Zu einem 32-bit Integer konvertieren
20642059
hash &= hash;
20652060
}
20662061
}
@@ -2159,9 +2154,12 @@ Dieser Leitfaden ist in den folgenden Sprachen verfügbar:
21592154
- [alivebao/clean-code-js](https://github.com/alivebao/clean-code-js)
21602155
- [beginor/clean-code-javascript](https://github.com/beginor/clean-code-javascript)
21612156
- ![kr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/South-Korea.png) **Koreanisch**: [qkraudghgh/clean-code-javascript-ko](https://github.com/qkraudghgh/clean-code-javascript-ko)
2157+
- ![pl](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Poland.png) **Polnisch**: [greg-dev/clean-code-javascript-pl](https://github.com/greg-dev/clean-code-javascript-pl)
21622158
- ![ru](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Russia.png) **Russisch**:
21632159
- [BoryaMogila/clean-code-javascript-ru/](https://github.com/BoryaMogila/clean-code-javascript-ru/)
21642160
- [maksugr/clean-code-javascript](https://github.com/maksugr/clean-code-javascript)
21652161
- ![vi](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Vietnam.png) **Vietnamesisch**: [hienvd/clean-code-javascript/](https://github.com/hienvd/clean-code-javascript/)
2162+
- ![ja](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Japan.png) **Japanisch**: [mitsuruog/clean-code-javascript/](https://github.com/mitsuruog/clean-code-javascript/)
2163+
- ![id](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Indonesia.png) **Indonesisch**: [andirkh/clean-code-javascript/](https://github.com/andirkh/clean-code-javascript/)
21662164

21672165
**[⬆ nach oben](#table-of-contents)**

0 commit comments

Comments
 (0)