Update article.md

This commit is contained in:
Ilya Kantor 2019-02-09 13:16:02 +03:00 committed by GitHub
parent d11abcea88
commit ec9a99d339
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -83,7 +83,7 @@ While choosing a name try to use the most abstract word. Like `obj`, `data`, `va
Give them a try. A young initiate may wonder -- are such names really useful for a ninja? Indeed, they are!
Sure, the variable name still means something. It says what's inside the variable: a string, a number or something else. But when an outsider tries to understand the code, he'll be surprised to see that there's actually no information at all! And will ultimately fail to alter your well-thought code.
Sure, the variable name still means something. It says what's inside the variable: a string, a number or something else. But when an outsider tries to understand the code, they'll be surprised to see that there's actually no information at all! And will ultimately fail to alter your well-thought code.
The value type is easy to find out by debugging. But what's the meaning of the variable? Which string/number does it store?
@ -153,7 +153,7 @@ function ninjaFunction(elem) {
}
```
A fellow programmer who wants to work with `elem` in the second half of the function will be surprised... Only during the debugging, after examining the code they will find out that he's working with a clone!
A fellow programmer who wants to work with `elem` in the second half of the function will be surprised... Only during the debugging, after examining the code they will find out that they're working with a clone!
Seen in code regularly. Deadly effective even against an experienced ninja.
@ -197,7 +197,7 @@ function render() {
A programmer who jumps inside the `render` will probably fail to notice that there's a local `user` shadowing the outer one.
Then he'll try to work with `user` assuming that it's the external variable, the result of `authenticateUser()`... The trap is sprung! Hello, debugger...
Then they'll try to work with `user` assuming that it's the external variable, the result of `authenticateUser()`... The trap is sprung! Hello, debugger...
## Side-effects everywhere!