Sunday, June 7, 2020

Rules and Naming Convention for Variables and constants

  1. Constant and variable names should have a combination of letters in lowercase (a to z) or uppercase (A to Z) or digits (0 to 9) or an underscore (_). For example:
    snake_case
    MACRO_CASE
    camelCase
    CapWords
  2. Create a name that makes sense. For example, vowel makes more sense than v.
  3. If you want to create a variable name having two words, use underscore to separate them. For example:
    my_name
    current_salary
  4. Use capital letters possible to declare a constant. For example:
    PI
    G
    MASS
    SPEED_OF_LIGHT
    TEMP
  5. Never use special symbols like !, @, #, $, %, etc.
  6. Don't start a variable name with a digit.

No comments:

Post a Comment