This commit is contained in:
Ilya Kantor 2019-06-09 15:59:34 +03:00
parent bef98f7087
commit 9cb33f4039

View file

@ -137,7 +137,7 @@ Instead, reuse existing names. Just write new values into them.
In a function try to use only variables passed as parameters. In a function try to use only variables passed as parameters.
That would make it really hard to identify what's exactly in the variable *now*. And also where it comes from. A person with weak intuition would have to analyze the code line-by-line and track the changes through every code branch. That would make it really hard to identify what's exactly in the variable *now*. And also where it comes from. The purpose is to develop the intuition and memory of a person reading the code. A person with weak intuition would have to analyze the code line-by-line and track the changes through every code branch.
**An advanced variant of the approach is to covertly (!) replace the value with something alike in the middle of a loop or a function.** **An advanced variant of the approach is to covertly (!) replace the value with something alike in the middle of a loop or a function.**
@ -169,8 +169,7 @@ A smart ninja puts underscores at one spot of code and evades them at other plac
Let everyone see how magnificent your entities are! Names like `superElement`, `megaFrame` and `niceItem` will definitely enlighten a reader. Let everyone see how magnificent your entities are! Names like `superElement`, `megaFrame` and `niceItem` will definitely enlighten a reader.
Indeed, from one hand, something is written: `super..`, `mega..`, `nice..` But from the other hand -- that brings no details. A reader may decide to look for a hidden meaning and meditate for an hour or two. Indeed, from one hand, something is written: `super..`, `mega..`, `nice..` But from the other hand -- that brings no details. A reader may decide to look for a hidden meaning and meditate for an hour or two of their paid working time.
## Overlap outer variables ## Overlap outer variables
@ -180,7 +179,7 @@ When in the light, can't see anything in the darkness.<br>
When in the darkness, can see everything in the light. When in the darkness, can see everything in the light.
``` ```
Use same names for variables inside and outside a function. As simple. No efforts required. Use same names for variables inside and outside a function. As simple. No efforts to invent new names.
```js ```js
let *!*user*/!* = authenticateUser(); let *!*user*/!* = authenticateUser();