Declaring Variables

Declaring is another way of saying creating a variable.

Explicit vs. Implicit

Explicit or “strict”

  • type is specified when the variable is created

A line of code looks like:

Processing, Java-based, and C-based example:

type variableName;

Implicit or “loose”

  • type is assumed

A line of code looks like:

JavaScript example:

var variableName;

or

Python example:

variablename = 0

Naming Conventions

Camel Casing

  • No Spaces

  • Starts lowercase

  • Starting with the second word, each word starts with a capital letter

Examples: highScore numPlayers objectToDisappear

Pascal Casing

  • No Spaces

  • Starts with an uppercase letter

  • Each word starts with a capital letter

  • Often used for functions and methods

Examples: HighScore NumPlayers ObjectToDisappear

All Upper Case

  • No Spaces

  • Spaces are replaced by underscores ( _ )

  • Often used for constant variables

Examples: HIGH_SCORE NUM_PLAYERS OBJECT_TO_DISAPPEAR

Last updated