flâneur — a map of the web's best reading

Ninja code

javascript.info · 1,747 words · saved by 1 readers

Cool, right? If you write like that, a developer who comes across this line and tries to understand what is the value of i is going to have a merry time. Then come to you, seeking for an answer. Tell them that shorter is always better. Initiate them into the paths of ninja. The Dao hides in wordlessness. Only the Dao is well begun and well completed. Another way to code shorter is to use single-letter variable names everywhere. Like a, b or c. A short variable disappears in the code like a real ninja in the forest. No one will be able to find it using “search” of the editor. And even if someone does, they won’t be able to “decipher” what the name a or b means. …But there’s an exception. A real ninja will never use i as the counter in a "for" loop. Anywhere, but not here. Look around, there are many more exotic letters. For instance, x or y. An exotic variable as a loop counter is especially cool if the loop body takes 1-2 pages (make it longer if you can). Then if someone looks deep in

Learning without thought is labor lost; thought without learning is perilous. Programmer ninjas of the past used these tricks to sharpen the mind of code maintainers. Code review gurus look for them in test tasks. Novice developers sometimes use them even better than programmer ninjas. Read them carefully and find out who you are – a ninja, a novice, or maybe a code reviewer? Irony detected Many try to follow ninja paths. Few succeed. Brevity is the soul of wit Make the code as short as possible. Show how smart you are. Let subtle language features guide you. For instance, take a look at this

Explore this link on the map →

saved by

related reading