8.1 · Lesson 7 of 7

Maintainable programs, procedures and functions

Syllabus 8.1.6Syllabus 8.1.7Syllabus 8.1.8

What this lesson covers

  • Write procedures and functions with parameters
  • Use local and global variables and library routines
  • Write maintainable programs

Key vocabulary

Maintainable program
A program that is easy for others to read, understand and change.
Meaningful identifier
A name that describes what a variable, constant, array or subroutine stores or does.
Comment
A note in the code for humans, ignored by the translator. Starts with // in pseudocode and # in Python.
Magic number
A value typed straight into the code with no explanation. Use a constant instead.
Subroutine
A named block of code that does a specific task, and can be called from elsewhere in the program.
Procedure
A subroutine that carries out a task but doesn't return a value. Run with CALL.
Function
A subroutine that returns a value, so it can be used in an expression.
Parameter
A value passed into a subroutine, listed in brackets in its header.
Argument
The actual value given to a parameter when a subroutine is called.
RETURN
Sends a value back from a function to where it was called.
Local variable
Declared inside a subroutine; can only be used there, and only exists while it runs.
Global variable
Declared in the main program; can be used anywhere in the program.

Check your learning

  • Quick check: 4 questions
  • Key vocabulary test: 12 terms
  • Activity 1: Meaningful identifiers · 6 questions
  • Activity 2: Which comment? · 5 questions
  • Activity 3: Procedure or function? · 6 questions
  • Activity 4: Trace the subroutine · 6 questions
  • Activity 5: Maintainable programs quiz · 8 questions
Loading Bits of Bytes…