Naming Conventions
Overview
How to name or identify variables in programming is often an organizational specific preference. This document presents common naming conventions for variables, functions, and objects in programming.
Information
- Use as short and as meaningful (semantic) of names as possible. They are easier to manage and understand. When meaningful, variable names communicate the purpose of the variable/component.
- Do not use spaces nor special characters in variable names. Use a naming convention instead.
- Common Naming Conventions
- Camel Case
Each word within a compound word name is capitalized except for the first word.julySales, getNewReport()
- Pascal Case
Each word within a compound word name is capitalized.JulySales, GetNewReport()
- Underscore or Snake Case
Each word within a compound word name is separated by an underscore.july_sales, get_new_report()
- Kebab Case
Each word is separated by a hyphen/minus sign.july-sales, get-new-report()
- Camel Case
"Whenever you develop code in a new language, get comfortable with the variable naming
conventions and always check with your team if your organization ever deviates from the
standard. It will make your code more readable and help your code blend with all of the code
commits, pulls and
merges." - TheServerSide.com
References
- JavaScript Variable Naming - MDN
- Clean Coding - Dev.to
- A guide to common variable naming conventions - TheServerSide.com