Skip to content

Modular Design with FunctionsActivities & Teaching Strategies

Active learning helps students grasp modular design because programming tasks feel abstract until they manipulate real code. Breaking problems into functions becomes tangible when students physically reorganize lines, rename blocks, and test each piece. This hands-on approach builds confidence that theory alone cannot provide.

Year 9Technologies4 activities20 min45 min

Learning Objectives

  1. 1Design a simple program that utilizes at least two distinct functions to perform a complex task.
  2. 2Analyze a given program to identify and explain the purpose of each function and its parameters.
  3. 3Compare the readability and efficiency of a program written with functions versus a monolithic script of equivalent functionality.
  4. 4Evaluate the trade-offs between creating a custom function for a repeated task and importing a function from a standard library.
  5. 5Deconstruct a complex problem into a series of smaller, logical steps that can be represented by individual functions.

Want a complete lesson plan with these objectives? Generate a Mission

30 min·Pairs

Pair Programming: Refactor a Monolith

Provide students with a long script full of repeated code, such as a basic calculator. In pairs, identify duplicate sections, extract them into functions with parameters, test each function separately, then integrate and run the full program. Pairs present one key change and its impact.

Prepare & details

Analyze how modularity improves the reliability and readability of a program?

Facilitation Tip: During Pair Programming: Refactor a Monolith, require students to track line counts and error logs before and after refactoring to make the benefits of modularity visible.

Setup: Groups at tables with access to research materials

Materials: Problem scenario document, KWL chart or inquiry framework, Resource library, Solution presentation template

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
45 min·Small Groups

Small Groups: Modular Problem Solver

Groups receive a complex task like simulating a simple inventory system. Brainstorm steps, assign functions for tasks like addItem or checkStock, pseudocode first, then code and test collaboratively. Demo the modular program to the class.

Prepare & details

Compare the trade-offs between writing a custom function and using a pre-existing library?

Facilitation Tip: For Small Groups: Modular Problem Solver, ask each group to swap their final functions with another group to test and debug, reinforcing reliability through peer review.

Setup: Groups at tables with access to research materials

Materials: Problem scenario document, KWL chart or inquiry framework, Resource library, Solution presentation template

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
25 min·Whole Class

Whole Class: Custom vs Library Challenge

Display code scenarios needing sorting or input validation. Class votes on custom function versus library use, then codes both versions live on the board. Discuss runtime, readability, and adaptability as a group.

Prepare & details

Design a strategy to break a complex problem into reusable steps.

Facilitation Tip: In Whole Class: Custom vs Library Challenge, provide identical starter code with two paths—one using built-in functions, one using custom functions—so students can directly compare trade-offs.

Setup: Groups at tables with access to research materials

Materials: Problem scenario document, KWL chart or inquiry framework, Resource library, Solution presentation template

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
20 min·Individual

Individual: Decomposition Mapping

Students pick a real-world process like planning a trip, list steps on paper, group into reusable functions with inputs/outputs. Convert to pseudocode, then implement one in a simple script and self-test.

Prepare & details

Analyze how modularity improves the reliability and readability of a program?

Facilitation Tip: For Individual: Decomposition Mapping, have students submit their diagrams alongside a brief written explanation of how each module interacts with others.

Setup: Groups at tables with access to research materials

Materials: Problem scenario document, KWL chart or inquiry framework, Resource library, Solution presentation template

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills

Teaching This Topic

Teach modular design by having students experience the pain of spaghetti code first, then guide them toward breaking problems into functions. Use concrete examples with measurable outcomes, like line counts and error logs, to prove modularity’s value. Avoid overwhelming students with abstract theory; instead, let them discover principles through structured activities and peer feedback.

What to Expect

Successful learning looks like students confidently splitting tasks into functions, explaining parameter use, and justifying code organization choices. They should measure improvements in readability and error rates, and articulate when to reuse functions versus library code.

These activities are a starting point. A full mission is the experience.

  • Complete facilitation script with teacher dialogue
  • Printable student materials, ready for class
  • Differentiation strategies for every learner
Generate a Mission

Watch Out for These Misconceptions

Common MisconceptionDuring Pair Programming: Refactor a Monolith, some students may resist breaking code into functions, arguing that it makes the program longer.

What to Teach Instead

Have students compare the line count and error log of the original monolithic script to their refactored version. Ask them to calculate the reduction in lines and count the errors after modularization to demonstrate that fewer lines and errors result from proper function use.

Common MisconceptionDuring Whole Class: Custom vs Library Challenge, students may default to using library functions without considering custom needs.

What to Teach Instead

Assign half the class to use library functions and the other half to write custom functions for the same task. After completing the challenge, hold a structured debate where groups present trade-offs based on flexibility, readability, and error handling.

Common MisconceptionDuring Small Groups: Modular Problem Solver, students might think functions cannot handle varied or complex inputs.

What to Teach Instead

Give each group a set of diverse inputs to pass to their functions, such as integers, strings, and mixed data types. Ask them to observe how parameters allow the same function to process different data correctly, then peer review each other’s parameter handling.

Assessment Ideas

Quick Check

After Pair Programming: Refactor a Monolith, provide students with a 20-line monolithic script and ask them to identify one block that can be turned into a function, rename it appropriately, and explain how this change improves readability and reduces errors.

Discussion Prompt

During Whole Class: Custom vs Library Challenge, pause the activity and ask each group to share one function they created and explain why it was necessary compared to using a library function, focusing on parameters and output requirements.

Exit Ticket

After Small Groups: Modular Problem Solver, have students complete an exit ticket stating one benefit of modular design they observed during peer testing and one challenge they faced when integrating functions.

Extensions & Scaffolding

  • Challenge: Ask students to extend their modular calculator by adding three new operations, each in a separate function, and document parameter requirements.
  • Scaffolding: Provide partially completed function templates with missing parameters or return statements for students who struggle to start.
  • Deeper exploration: Introduce global versus local variables by having students modify their functions to use variables from different scopes, then analyze the effects on program behavior.

Key Vocabulary

FunctionA named block of code designed to perform a specific task. Functions can accept inputs (parameters) and may return an output.
ProcedureSimilar to a function, but typically does not return a value. It executes a sequence of commands.
ModularityThe practice of breaking down a large software system into smaller, independent, and interchangeable parts or modules.
ParameterA variable listed inside the parentheses in a function definition. It acts as a placeholder for a value that will be passed into the function.
CallTo execute a function. When a function is called, the program's control transfers to the function's code block.

Ready to teach Modular Design with Functions?

Generate a full mission with everything you need

Generate a Mission