What are Variable Naming Rules?
The variable naming rule is a set of rules set in order to name a memory location during coding a program for easy access.
Variable Naming Rules Are The Following
- Use simple, descriptive variable names.
- Never use l (lowercase L) or O (uppercase O) as variable names.
- Don’t use variable names that differ by only one or two characters. Make every name obviously different from every other name.
- For variable names consisting of two words joined together, separate the words by “_”: like max_length
- Use similar names for variables that perform similar functions.
- When creating a two-word variable name where the words can be put in any order, always put the more important word first.
- e.g. max_elevation instead of elevation_max
- Use standard prefixes:
- . n_ (“number of”) → n_points
- Follow every variable declaration with a comment that defines it.
int leve2; int total_numbers; int totalMarks; float n_points;
int 2numbers; int total marks; int 22;
Variable Naming Rules
Support us by sharing this post