DEV Community

loading...

Naming cheatsheet

Khang
With ❤ crafting - For 💯 striving
・1 min read

I discovered a generally helpful and practical Github guideline repo with respect to naming things. Applying these could tremendously improve one's code readability and maintainability. Enjoy and don't hesitate to place a star on the repo to appreciate the author.

GitHub logo kettanaito / naming-cheatsheet

Comprehensive language-agnostic guidelines on variables naming. Home of the A/HC/LC pattern.

Naming cheatsheet

Naming cheatsheet



Naming things is hard. This sheet attempts to make it easier.

Although these suggestions can be applied to any programming language, I will use JavaScript to illustrate them in practice.

English language

Use English language when naming your variables and functions.

/* Bad */
const primerNombre = 'Gustavo'
const amigos = ['Kate', 'John']
/* Good */
const firstName = 'Gustavo'
const friends = ['Kate', 'John']
Enter fullscreen mode Exit fullscreen mode

Like it or not, English is the dominant language in programming: the syntax of all programming languages is written in English, as well as countless documentations and educational materials. By writing your code in English you dramatically increase its cohesiveness.

Naming convention

Pick one naming convention and follow it. It may be camelCase

Discussion (0)