Skip to content
Computing · Year 9

Active learning ideas

Modular Programming with Functions

Active learning works for modular programming because students must repeatedly decide how to split tasks, name units, and connect them. These decisions cement the value of functions beyond syntax, turning abstract ideas into concrete, reusable tools.

National Curriculum Attainment TargetsKS3: Computing - Programming and DevelopmentKS3: Computing - Computational Thinking
25–45 minPairs → Whole Class4 activities

Activity 01

Pair Programming: Modular Calculator Build

Pairs outline calculator operations, write separate functions for add, subtract, multiply, and divide, then create a main loop for user input. Test with edge cases like division by zero. Pairs demo their calculators to the class.

Justify why modular programming is crucial for developing complex software applications.

Facilitation TipDuring Pair Programming: Modular Calculator Build, circulate and ask each pair to explain why they placed a specific operation in a function rather than in the main loop.

What to look forProvide students with a short, non-modular Python script (e.g., a simple text-based adventure game with repeated code blocks). Ask them to identify at least two sections of code that could be turned into functions and write down the proposed function names and their purpose.

ApplyAnalyzeEvaluateCreateRelationship SkillsDecision-MakingSelf-Management
Generate Complete Lesson

Activity 02

Collaborative Problem-Solving35 min · Small Groups

Small Groups: Refactoring Relay

Provide a single-script program with repeated code. Groups take turns extracting functions for common tasks, passing the updated code along. End with group presentations on time saved in testing.

Design a program for a simple calculator, separating operations into distinct functions.

Facilitation TipDuring Small Groups: Refactoring Relay, assign each group a different monolithic script so they experience varied decomposition paths and can compare approaches afterward.

What to look forPresent students with a scenario: 'You need to write a program that takes user input for their name, age, and email, validates each input, and then prints a welcome message.' Ask them to list the distinct functions they would create and briefly describe what each function would do.

ApplyAnalyzeEvaluateCreateRelationship SkillsDecision-MakingSelf-Management
Generate Complete Lesson

Activity 03

Collaborative Problem-Solving25 min · Whole Class

Whole Class: Modular vs Monolithic Debug

Display two program versions, one modular and one not, each with bugs. Class discusses and votes on fix ease, then codes fixes collaboratively on shared screens.

Evaluate how well-defined functions improve the debugging process.

Facilitation TipDuring Whole Class: Modular vs Monolithic Debug, deliberately introduce a bug in the monolithic version first so students feel the pain before seeing the fix in the modular version.

What to look forStudents work in pairs to create a simple calculator program using functions for addition, subtraction, multiplication, and division. After completion, they swap programs and review: Does each operation have its own function? Is the main part of the program clear and easy to follow? Are there any repeated lines of code that could be functions?

ApplyAnalyzeEvaluateCreateRelationship SkillsDecision-MakingSelf-Management
Generate Complete Lesson

Activity 04

Collaborative Problem-Solving30 min · Individual

Individual: Function Design Portfolio

Students independently design three functions for a text adventure game, like movement or inventory checks. Peer review follows, with revisions based on feedback.

Justify why modular programming is crucial for developing complex software applications.

Facilitation TipDuring Individual: Function Design Portfolio, require students to submit both code and a short rationale paragraph for each function they create.

What to look forProvide students with a short, non-modular Python script (e.g., a simple text-based adventure game with repeated code blocks). Ask them to identify at least two sections of code that could be turned into functions and write down the proposed function names and their purpose.

ApplyAnalyzeEvaluateCreateRelationship SkillsDecision-MakingSelf-Management
Generate Complete Lesson

A few notes on teaching this unit

Teachers approach this topic by making decomposition visible: use color coding to mark function boundaries in shared code, and insist on naming conventions that reveal purpose. Avoid rushing to solutions; instead, pause after each function is written and ask, 'How could another part of the program use this without rewriting?' Research supports frequent, low-stakes refactoring to build mental models of modularity.

Successful learning looks like students designing clear function boundaries, reusing code without duplication, and confidently tracing data flow between functions and the main program. You will see fewer global variables and more comments explaining function purposes.


Watch Out for These Misconceptions

  • During Pair Programming: Modular Calculator Build, students may argue that functions just make code longer without benefits.

    During this activity, have each pair time how long it takes to find and fix a deliberate bug in their first monolithic version versus in their refactored version with separate functions.

  • During Small Groups: Refactoring Relay, students might believe everything belongs in the main program body.

    During this relay, ask groups to count how many lines of repeated code they remove by creating functions and compare that to the total lines in their original scripts.

  • During Function Design Portfolio, students often think functions cannot share or modify data effectively.

    In this portfolio, require students to use parameters and return values for all data sharing, then review their submissions to highlight cases where globals were replaced.


Methods used in this brief