Naming
Common Principles
-
Choose names that clearly describe the purpose. Names should be as short as possible but long enough to convey meaning.
-
Use full words instead of abbreviations.
-
Avoid reserved words as names.
-
Stick to a consistent naming convention throughout your codebase. For JS they are camelCase and PascalCase.
Variables
-
Use nouns for variables.
-
Use Plurals for arrays and collections.
-
Except for loop indices, avoid using single character names.
-
Use named constants instead of hard-coding values directly in your code.
Functions
-
Use verbs for functions (because functions are actions).
-
If the function is predicate the name is often starting with is, has, can, or should.
-
Function names should clearly indicate if they have side effects.