What are meaningful identifiers?
- Meaningful identifiers are sensible names used for variables, constants or subroutines
- A meaningful identifier must be used to help aid the maintainability of a program
- An example would be a variable used for an input of a users' first name
Meaningful Identifier |
Poor Identifier |
name ← USERINPUT
IF name == "Mike" THEN
cost ← 100 * 0.5
ELSE
OUTPUT name + " your total is: " + cost
|
a ← USERINPUT
IF a == "Mike" THEN
b ← 100 * 0.5
ELSE
OUTPUT a + " your total is: " + b
|
Examples of using subroutines
SUBROUTINE Information()
first_name ← USERINPUT
surname ← USERINPUT
ENDSUBROUTINE
|
SUBROUTINE Tax(pay_per_hour, hours_worked)
total ← pay_per_hour * hours_worked
net_pay ← total * 0.8
RETURN net_pay
ENDSUBROUTINE
|
//Main program starts here
Information()
OUTPUT(Tax)