Single lesson · Written for OCR J277

Maintainable code – OCR GCSE Computer Science lesson (J277)

Pupils learn to improve the maintainability of a program using sensible names, comments, indentation and subprograms, and explain why each helps.

Also in a bundle Cyber Security and Robust Programs – OCR GCSE Computer Science lessons (J277) 14 lessons for £39 · save 30% on buying separately

Lesson 10 of 14 in unit 11.1 Cyber Security and Robust Programs, taught in Year 11, Autumn 1. It answers one big question: What makes code easy for someone else to change?

By the end, pupils can improve the maintainability of a program using sensible names, comments, indentation and subprograms, and explain why each helps.

The Build (the main task)
Make Kickstand's stock-check program maintainable: rename its variables, add comments, fix its indentation and move the repeated code into a subprogram.
Support version
A table pairing each bad name with a choice of three new names, and the subprogram's def line given.
Challenge
Explain why a maintainable program is cheaper for Kickstand when it hires a new programmer.
Real-world link
Kickstand hires a new programmer who cannot understand the shop's old stock program.
Key words
Maintainability, Naming convention and Readable, each with a definition, an icon and a common mix-up on the key vocabulary slide.
Misconceptions it tackles
“Maintainable code means code that runs faster”; “Any variable name is fine as long as the program runs”.
OCR J277 specification
2.3.1 (defensive design: anticipating misuse, authentication, input validation, and maintainability (subprograms, naming conventions, indentation and comments)).

Every lesson follows the same Code & Commerce structure: a Bell Task recall starter, key vocabulary with definitions and icons, short teaching chunks with a check before pupils move on, The Build (one main task), challenge questions that get harder, and an exit question. Answers reveal one at a time on the slides, and everything is editable PowerPoint and Word.

Pupils can do it all on paper.

Also sold in the Cyber Security and Robust Programs unit bundle, which includes the medium term plan, and in the full-year and complete-course bundles.

What's included

  • Slide deck (PowerPoint)
  • Lesson plan (Word)
  • Worksheet (Word)
  • Support worksheet with scaffolds (Word)
  • Single-teacher licence: use and adapt it with your own classes

More for GCSE Computer Science (OCR)

See all

Written for the specifications named. Not endorsed by or affiliated with any exam board.