Skip to content
Computing · Year 7 · Computational Thinking and Logic · Autumn Term

Introduction to Functions and Procedures

Understanding how to create and use custom blocks (functions) to modularize code and promote reusability.

National Curriculum Attainment TargetsKS3: Computing - Programming and Development

About This Topic

Functions and procedures introduce students to modular programming by creating custom blocks in Scratch that encapsulate repeated tasks. Year 7 pupils learn to define these blocks, pass inputs through parameters, and call them from main scripts, which organizes code into logical units. This directly addresses curriculum standards in KS3 Computing for programming and development, as students explain benefits like reusability, design blocks for tasks such as sprite animations, and analyze how functions enhance readability and maintenance.

In the unit on Computational Thinking and Logic, this topic builds decomposition skills by breaking complex programs into smaller, manageable parts. Students see how functions reduce repetition, similar to real-world software design, and prepare for advanced languages. Collaborative debugging reinforces logic flow, while testing custom blocks reveals how parameters make code flexible.

Active learning suits this topic well. When students pair program functions for shared projects, they experiment with calls and inputs, gaining instant feedback from Scratch's visual interface. Group challenges to refactor messy code into functions clarify abstract benefits through hands-on iteration and peer review.

Key Questions

  1. Explain the benefits of using functions to organize code.
  2. Design a custom block in Scratch to perform a specific task.
  3. Analyze how functions improve code readability and maintainability.

Learning Objectives

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

Before You Start

Sequencing and Basic Scratch Commands

Why: Students must be familiar with basic Scratch commands and how to arrange them in a sequence before they can group them into a function.

Loops

Why: Understanding loops helps students recognize repetitive patterns in code, which is a key motivator for using functions to avoid repetition.

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.

Watch Out for These Misconceptions

Common MisconceptionCustom blocks run automatically once defined.

What to Teach Instead

Blocks only execute when called from a script. Pair testing activities show students they must add 'call' blocks explicitly, helping them trace execution flow visually in Scratch. Peer explanations during debugging solidify this understanding.

Common MisconceptionFunctions without parameters are pointless.

What to Teach Instead

Simple procedures handle fixed tasks efficiently, like a 'jump' animation. Group refactoring challenges demonstrate how even basic blocks cut repetition, as students measure code savings and discuss flexibility trade-offs in reviews.

Common MisconceptionFunctions make code harder to read.

What to Teach Instead

Well-named blocks with clear parameters improve readability. Collaborative code reviews in small groups let students critique and rename blocks, revealing how modularity aids maintenance through real project examples.

Active Learning Ideas

See all activities

Real-World Connections

  • Software developers use functions extensively when building video games like 'Minecraft'. For example, a 'jump' function might be called whenever the player presses the spacebar, ensuring consistent jump behavior across the game.
  • Web designers use functions to create interactive elements on websites. A 'play video' function could be triggered by a button click, handling all the necessary steps to start and control the video playback.

Assessment Ideas

Exit Ticket

Provide students with a simple Scratch project that repeats a sprite movement three times. Ask them to rewrite the project using a custom block for the movement and explain in one sentence why this is better.

Quick Check

Display two Scratch scripts side-by-side: one with repeated code and one refactored using a custom block. Ask students to identify which script uses a function and explain one benefit they observe.

Discussion Prompt

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

Frequently Asked Questions

How do you introduce functions in Scratch for Year 7?
Start with a demo of repetitive code, then guide students to extract a custom block live. Use parameters early for inputs like numbers or variables. Follow with scaffolded templates that fade support, ensuring all students build and call at least two blocks successfully in 20 minutes.
What are the benefits of teaching functions in KS3 Computing?
Functions teach decomposition and abstraction, core computational thinking skills. They promote reusable code, mirroring professional practices, and make debugging easier by isolating logic. Students gain confidence in larger projects, as modular code reduces errors and supports collaboration in Autumn term units.
How can active learning help teach functions and procedures?
Pair programming and group refactoring let students actively build, test, and iterate functions with immediate Scratch feedback. Challenges like 'remix this code' encourage experimentation, while peer teaching during shares corrects misconceptions on-the-spot. This hands-on approach makes abstract modularity concrete and boosts retention through collaboration.
Common mistakes when students first use custom blocks?
Pupils often forget to call blocks or misuse parameters, causing scripts to halt. Address with checkpoint rubrics during pair work: check definitions, calls, and tests. Visual flowcharts as extensions help trace issues, turning errors into teachable moments in whole-class debriefs.