2.3.10

Identifiers

Test yourself

Identifiers

Identifiers are the names given to variables, constants, and subroutines.

Illustrative background for VariablesIllustrative background for Variables ?? "content

Variables

  • Variables should have lowercase names, with each word separated by an underscore. For example:
    • this_is_my_variable
    • user_money
  • Variable should also have descriptive names, for example user_money is much better than this_is_my_variable.
Illustrative background for ConstantsIllustrative background for Constants ?? "content

Constants

  • Constants should be named using the same rules as variables, but uppercase.
Illustrative background for SubroutinesIllustrative background for Subroutines ?? "content

Subroutines

  • Subroutines should have lowercase names, with each word separated by an underscore. For example:
    • calculate_sum()
    • get_user_id()
  • Subroutines should have descriptive names where possible.
Illustrative background for Global rulesIllustrative background for Global rules ?? "content

Global rules

  • In general, all identifiers should be descriptive.
  • Characters which might be confused should be avoided, for example:
    • 0 and O.
    • 1 and l (lower case L).

Jump to other topics

1Computational Thinking & Algorithms

2Programming

3Hardware & Software

4Data

5The Internet

6Online Safety & Security

Go student ad image

Unlock your full potential with GoStudent tutoring

  • Affordable 1:1 tutoring from the comfort of your home

  • Tutors are matched to your specific learning needs

  • 30+ school subjects covered

Book a free trial lesson