Mc’rib // Apostrophe is not an alphanumeric character
something_&_something // ampersand is not an alphanumeric character
We should keep these things in mind while defining identifiers. These are not a compulsion and will not result in a compile-time error. These are more like suggestions and everyone in the industry follows it:
a. Naming A Custom Type
The name should start with an uppercase character.
The remaining characters should be in lowercase if the identifier consists of one word.
If the name contains more than one word then the first character of every word should be in uppercase and the remaining characters should be in lowercase.
Examples: Executable, Student, BatchTiming, CourceDetails, UserInFormation etc.
b. Naming a Method or Object or Variable
The name should start with a lowercase letter.
If it contains multiple words then from second word onwards the first character should be uppercase and the remaining should be in lowercase. For e.g. email, employeePhone, branchName, getCourceDetailsByCourceId(), getName(), isValid() etc.
c. Naming a Constant
All the characters should be uppercase.
If the name contains multiple words then we need to use _ (underscore) symbol as a separator between two words. For eg MIN_VALUE, FULL_COURCE_FEE, etc.