Variables in Alice3

After deciding on a type, the programmer must select a good name for the variable.

  • A variable name must start with a letter of the alphabet or an underscore.
  • After the first letter, there can be additional letters, digits and underscores.
  • There cannot be any spaces in a variable name.
  • Words that have a special meaning such as Do or Boolean should not be used to name variables.
  • The name of the variable should indicate its purpose. Variable names like a, b and c are not
    very good names for variables unless you are using them for the three sides of a triangle.
  • If two words are joined together (you can’t have any spaces), a capital letter for the second
    word or an underscore can improve the clarity. Example: hoursWorked.
  • NEXT: Drill on names