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

Unlock your full potential with Seneca Premium

  • Unlimited access to 10,000+ open-ended exam questions

  • Mini-mock exams based on your study history

  • Unlock 800+ premium courses & e-books

Get started with Seneca Premium