Lesson Plan

Lesson Plan
Grade: Date: 17/01/2026
Subject: Computer Science
Lesson Topic: Show understanding of the various stages in the compilation of a program
Learning Objective/s:
  • Describe each compilation stage and its input‑output relationship.
  • Explain the role of the symbol table and when it is accessed.
  • Compare lexical, syntax, and semantic analysis in terms of error detection.
  • Evaluate how optimisation improves program performance.
  • Illustrate the complete flow from source code to executable using a diagram.
Materials Needed:
  • Projector and screen
  • Whiteboard and markers
  • Printed handout of the compilation‑stage diagram
  • Sample source‑code snippets
  • IDE/Compiler demo (e.g., GCC)
  • Worksheet for stage‑matching activity
Introduction:

Begin with the question “What happens when you run a program you wrote?” to activate prior knowledge of coding. Briefly recap that code must be transformed before the computer can execute it. Explain that today’s success criteria are to label each compilation stage and describe its purpose.

Lesson Structure:
  1. Do‑now (5 minutes): Students write the steps they think occur before a program runs; share a few responses.
  2. Mini‑lecture with slides (15 minutes): Present the seven compilation stages, show the flow diagram, and highlight inputs/outputs.
  3. Interactive walkthrough (20 minutes): Using a short code example, demonstrate tokenisation, parsing to an AST, and generation of intermediate code; ask probing questions after each stage.
  4. Group worksheet activity (15 minutes): Teams match given inputs and outputs to the correct stage and justify their choices.
  5. Optimization discussion (10 minutes): Show examples of constant folding and dead‑code elimination; discuss why early optimisation matters.
  6. Exit ticket (5 minutes): Each student writes one sentence explaining the purpose of linking/loading.
Conclusion:

Recap the full compilation pipeline, emphasizing how each stage builds on the previous one. Collect exit tickets and address any lingering misconceptions. For homework, students create a flowchart of the compilation stages for a different programming language of their choice.