Skip to content

Commit f6ab827

Browse files
authored
Changing order in example of *Functions should only be one level of abstraction*
Like said in https://github.com/ryanmcdermott/clean-code-javascript#function-callers-and-callees-should-be-close, the code is read from top to bottom, so I'd prefer the definition of the *function parseBetterJSAlternative* above the functions called within.
1 parent bd05a5f commit f6ab827

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ saveCityZipCode(city, zipCode);
113113
```
114114
**[⬆ back to top](#table-of-contents)**
115115

116-
### Avoid Mental Mapping
116+
### Avoid Mental Mappingf
117117
Explicit is better than implicit.
118118

119119
**Bad:**
@@ -343,6 +343,14 @@ function parseBetterJSAlternative(code) {
343343

344344
**Good:**
345345
```javascript
346+
function parseBetterJSAlternative(code) {
347+
const tokens = tokenize(code);
348+
const ast = lexer(tokens);
349+
ast.forEach((node) => {
350+
// parse...
351+
});
352+
}
353+
346354
function tokenize(code) {
347355
const REGEXES = [
348356
// ...
@@ -367,14 +375,6 @@ function lexer(tokens) {
367375

368376
return ast;
369377
}
370-
371-
function parseBetterJSAlternative(code) {
372-
const tokens = tokenize(code);
373-
const ast = lexer(tokens);
374-
ast.forEach((node) => {
375-
// parse...
376-
});
377-
}
378378
```
379379
**[⬆ back to top](#table-of-contents)**
380380

0 commit comments

Comments
 (0)