Skip to content

Introduction to Functions and ProceduresActivities & Teaching Strategies

Active learning works well here because students need to see the immediate payoff of modular coding. Defining, calling, and testing custom blocks in Scratch lets pupils experience firsthand how functions streamline repeated tasks, which builds confidence and clarity in programming logic.

Year 7Computing4 activities30 min45 min

Learning Objectives

  1. 1Design a custom Scratch block to perform a specific animation sequence.
  2. 2Explain how functions reduce code duplication in a given Scratch project.
  3. 3Analyze a Scratch project to identify opportunities for refactoring using custom blocks.
  4. 4Compare the efficiency of a script using functions versus a script without functions.

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

30 min·Pairs

Pair Programming: Custom Movement Block

Students work in pairs to create a 'moveForward' custom block with distance and speed parameters. They test it by calling the block multiple times in a sprite script, then swap roles to modify and debug. Pairs combine blocks into a simple obstacle course.

Prepare & details

Explain the benefits of using functions to organize code.

Facilitation Tip: During Pair Programming, circulate and prompt pairs to verbalize each step as they define the block and add the call, reinforcing the link between definition and execution.

Setup: Presentation area at front, or multiple teaching stations

Materials: Topic assignment cards, Lesson planning template, Peer feedback form, Visual aid supplies

UnderstandApplyAnalyzeCreateSelf-ManagementRelationship Skills
45 min·Small Groups

Small Groups: Reusable Game Functions

Groups design three custom blocks: score update, enemy spawn, and sound effect. Each member codes one block, then they integrate into a shared game project. Groups present how functions reduce code length and fix issues collaboratively.

Prepare & details

Design a custom block in Scratch to perform a specific task.

Facilitation Tip: For Reusable Game Functions, provide a starter project with duplicated code so groups can directly compare the original and refactored versions, making the benefits of modularity visible.

Setup: Presentation area at front, or multiple teaching stations

Materials: Topic assignment cards, Lesson planning template, Peer feedback form, Visual aid supplies

UnderstandApplyAnalyzeCreateSelf-ManagementRelationship Skills
35 min·Whole Class

Whole Class: Function Refactoring Challenge

Display a long, repetitive Scratch script on the board. As a class, identify repeatable sections and vote on custom blocks to create. Students then replicate and refactor individually on their computers, comparing before-and-after code.

Prepare & details

Analyze how functions improve code readability and maintainability.

Facilitation Tip: In the Function Refactoring Challenge, assign roles within groups so every student contributes: one refactors, one tests, one records benefits, ensuring active participation and accountability.

Setup: Presentation area at front, or multiple teaching stations

Materials: Topic assignment cards, Lesson planning template, Peer feedback form, Visual aid supplies

UnderstandApplyAnalyzeCreateSelf-ManagementRelationship Skills
40 min·Individual

Individual: Personal Procedure Portfolio

Each student builds five custom procedures for everyday tasks, like drawing shapes or checking conditions. They document inputs, outputs, and usage in a digital portfolio, then self-test by calling blocks in new projects.

Prepare & details

Explain the benefits of using functions to organize code.

Facilitation Tip: Have students in the Personal Procedure Portfolio include a short reflection on one block they created, describing what it does and why they named it that way, to strengthen metacognition.

Setup: Presentation area at front, or multiple teaching stations

Materials: Topic assignment cards, Lesson planning template, Peer feedback form, Visual aid supplies

UnderstandApplyAnalyzeCreateSelf-ManagementRelationship Skills

Teaching This Topic

Teachers should model naming conventions and parameter use before students create their own blocks. Start with simple, single-purpose procedures so students grasp the concept of encapsulation before tackling more complex inputs. Avoid skipping the step of calling the block explicitly in a script; this is where many misconceptions about execution begin. Research shows that students learn modularity best when they repeatedly see the same task performed both ways—once duplicated, once refactored—so plan comparisons that make the difference obvious.

What to Expect

By the end of these activities, students will confidently define custom blocks, pass parameters, and call them from scripts. They will also explain how reusable blocks improve readability, reduce repetition, and make projects easier to maintain and debug.

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, watch for students who assume their custom block runs automatically once defined.

What to Teach Instead

Prompt pairs to trace the script step-by-step and add a call block explicitly. Ask them to predict what will happen before running the code, then explain why the block only executes when called.

Common MisconceptionDuring Reusable Game Functions, watch for students who believe functions without parameters have no value.

What to Teach Instead

Have groups measure the number of duplicated lines before and after refactoring. Ask them to discuss in their small groups whether the fixed 'jump' animation improves readability and why fixed tasks still benefit from modular design.

Common MisconceptionDuring Function Refactoring Challenge, watch for students who think functions make code harder to read.

What to Teach Instead

After refactoring, have each group present their renamed blocks and explain how the new names clarify the script’s purpose. Use a gallery walk so students see multiple examples of clear, modular naming.

Assessment Ideas

Exit Ticket

After Pair Programming, give students a short starter project with repeated sprite movement. Ask them to rewrite it using a custom block and explain in one sentence why using a block is better than repeating the code.

Quick Check

During Reusable Game Functions, display two scripts side-by-side: one with repeated code and one refactored using a custom block. Ask students to identify which uses a function and explain one benefit they observe.

Discussion Prompt

After the Function Refactoring Challenge, pose the question: 'Imagine you are building a robot that needs to draw a square multiple times. How would using a custom block help you design the code for this robot, and what information might you need to give the block each time it draws a square?'

Extensions & Scaffolding

  • Challenge: Ask students to create a block with two parameters, such as 'move sprite to x: and y:', and then use it to animate a sprite along a plotted path.
  • Scaffolding: Provide partially completed blocks with missing parameter names or call statements for students to fill in during the Pair Programming activity.
  • Deeper exploration: Have students research and implement a function with a return value, then demonstrate how it can be used in a conditional statement to make decisions in their game.

Key Vocabulary

FunctionA block of code that performs a specific task and can be reused multiple times. In Scratch, these are called 'My Blocks'.
ProcedureAnother term for a function, emphasizing a set of steps to accomplish a task. Often used interchangeably with 'function'.
Custom BlockA user-defined block in Scratch that groups together a sequence of commands to perform a specific action.
ParameterA variable within a function's definition that allows it to accept input values, making the function more flexible.
ReusabilityThe ability of a piece of code, like a function, to be used in multiple parts of a program or in different programs without being rewritten.

Ready to teach Introduction to Functions and Procedures?

Generate a full mission with everything you need

Generate a Mission