4 Naming Conventions used in Programming
4 NAMING CONVENTIONS USED IN PROGRAMMING
Knowing how to name your variables, classes, objects, functions, etc is such an important skill to have as a developer.
Having the right system and approach in place will make or break you code.
HERE ARE 4 CONVENTIONAL TO KEEP IN MIND --->
1. for ARRAYS
- Make variable names plural because arrays consists of more than one item.
DON'T: var flag = ["India", "America", "Philippines"];
DO: var flagNames = ["India", "America", "Philippines"];
2. for BOOLEANS
- Use prefixes like "is", "has", and "can" to help infer the type of variable.
DON'T: var cool = true;
DO: var isCool = true;
3. for FUNCTIONS
- Have two parts to the name - 1) Verb 2) Noun. This because functions perform some type of action on a resource.
4. WRITING STYLES
- Depending on the language, you should use one case over the others.
var hackUniversity = "@hackuniversity"' //camelCase
var HackUniversity = "@hackuniversity"' //PascallCase
var hack_university = "@hackuniversity"' //snake_case
var hack-university = "@hackuniversity"' //kebab-case
var hackuniversity = "@hackuniversity"' //lazycase