by rShergold · 5y ago · 0 comments
Code it read 100 times more than it is written/edited. Writing in a high level language is writing for a human first and a computer second.
As a general rule of thumb a variable name should be as big as the scope of that variable.
* If it's scope is one line it's okay to use a single letter.
deletedDocuments = documents.find(d => d.deleted)
* If it's within a block normally one or two words will be fine.* If it's one file, 3 or 4 words.
* If it's global it should read like the opening paragraph to war and peace.
The last two are generally indications that something has gone wrong with how you are encapsulating your code and you should consider a refactor. However you will often have no other option in which case always lean towards more descriptive not less.
No comments yet.