Concepts > Identifiers and Naming Conventions
 
 
 
 
Identifiers
 
 

An identifier is a name given to a variable, function or an object.

 
 
 
  Naming Rules:
•  An identifier must start with a letter, underscore or a dollar sign.
•  You can use a number in an identifier name but it should not be the starting character of the name. Eg: 1mc is invalid but mc1 is valid.
•  An identifier cannot have spaces. If the name uses more than one word, then those words should be concatenated by a character such as underscore.
 
     
 

Some Naming Conventions:

 
 

Though you are free to use your own conventions while naming but most of the time, when your application becomes complex with time, you tend to find many variables making no sense. There are three basic formats for naming identifiers that are:

 
 

Constants: These variables contain the same value throughout their life. While defining constants, they are written in complete uppercase. E.g. Math.PI

 
 

Functions and Instance Variables: Most of the variables that will be used are instance variables. Their values keep on changing throughout their life. Instance variable names start with a lowercase letter and each additional letter starts with a capital. You should also suffix a hint at the end of the variable to signify which type of variable it is. E.g. firstName_str

 
 

Class Constructors: Class constructors are also written without spaces but a capital at the starting of each new word. E.g. SingleChoiceQuestion