Skip to content
Technologies · Foundation · Creating with Code · Term 3

Functions and Procedures: Modular Code

Introducing functions and procedures to create modular, reusable code, improving program organization and efficiency.

ACARA Content DescriptionsAC9TDIP03

About This Topic

Functions and procedures introduce modular code by letting students define reusable blocks of instructions, which improves program organization and efficiency. In Foundation Technologies, use block-based tools like ScratchJr to create simple functions, such as a 'clap hands' procedure with motion and sound blocks. Students construct programs that call these functions multiple times, aligning with AC9TDIP03 and key questions on breaking tasks into parts, reusability benefits, and when to use functions over sequential code.

This topic builds computational thinking through decomposition and abstraction. Students analyze how modular code makes programs shorter and easier to read, then justify choices by comparing a repetitive dance sequence to one with a reusable 'dance step' function. Connections to the Creating with Code unit reinforce logical sequencing from prior lessons.

Active learning excels with this content because students experience reusability firsthand as they drag, snap, and test blocks. Pair debugging and class remixing sessions reveal how one change in a function updates all calls, making abstract efficiency gains visible and motivating through immediate success.

Key Questions

  1. Construct a program that utilizes functions to break down complex tasks into smaller parts.
  2. Analyze the benefits of using functions for code reusability and readability.
  3. Justify when to create a new function versus writing sequential code.

Learning Objectives

  • Create a simple program using ScratchJr that defines and calls a custom function to perform a sequence of actions.
  • Compare the length and readability of a program written with repeated code versus one using a defined function.
  • Explain how defining a function helps to organize a program into smaller, manageable parts.
  • Justify when it is more efficient to create a new function instead of writing sequential code for a task.

Before You Start

Sequencing Instructions

Why: Students need to understand how to arrange blocks in a specific order to make a program work before they can group them into a function.

Basic Block Coding in ScratchJr

Why: Familiarity with the ScratchJr interface and basic motion, sound, and appearance blocks is necessary to create and call functions.

Key Vocabulary

FunctionA named set of instructions that performs a specific task. It can be used multiple times in a program.
ProcedureAnother name for a function, especially when it is a set of steps to follow. In block-based coding, this is often how functions are referred to.
CallTo use or run a function that has already been defined. You 'call' the function by its name.
Modular CodeCode that is broken down into smaller, independent parts or modules (like functions), making it easier to manage and reuse.

Watch Out for These Misconceptions

Common MisconceptionFunctions are only needed for very long programs.

What to Teach Instead

Short repeats also benefit from functions, as students see when comparing code length in pair builds. Active comparison activities help them count blocks and justify modularity for any repetition.

Common MisconceptionCalling a function runs all code at once.

What to Teach Instead

Functions execute only when called, step by step. Tracing calls during whole-class debugging sessions clarifies sequence, reducing confusion through visual block execution.

Common MisconceptionFunctions make code work automatically without testing.

What to Teach Instead

Functions require testing like any code. Small group remixing exposes errors in shared procedures, teaching iterative refinement through peer review.

Active Learning Ideas

See all activities

Real-World Connections

  • Video game developers use functions to create reusable actions for characters, such as 'jump' or 'attack'. This saves them from writing the same code over and over for each character or situation.
  • App designers use functions to build interactive elements. For example, a 'play sound' function can be called whenever a button is tapped, ensuring consistent sound effects across an application.

Assessment Ideas

Exit Ticket

Give students a simple task, like making a character move and say 'hello'. Ask them to draw or describe how they would use a function to do this. Then, ask them to write one sentence explaining why using a function is helpful for this task.

Quick Check

Observe students as they work in ScratchJr. Ask them: 'Can you show me where you defined your function?' and 'Where in your program do you use that function?' Note which students can identify and explain these parts.

Discussion Prompt

Present two versions of a simple animation: one with repeated blocks for a character's dance, and one using a 'dance move' function. Ask students: 'Which program is shorter? Which one is easier to understand? Why?'

Frequently Asked Questions

How do I introduce functions in Foundation coding lessons?
Start with familiar repeats, like multiple 'forward' blocks in a path. Model defining a 'go straight' function in ScratchJr, call it thrice, then let students replicate. Link to daily routines, such as reusable steps in brushing teeth, to build intuition before coding.
What are the benefits of modular code for young students?
Modular code teaches reusability, cutting repetition and errors, while boosting readability for sharing. Students gain confidence editing one function to update everywhere, fostering problem-solving. It scaffolds advanced programming by embedding decomposition early.
How can active learning help students grasp functions and procedures?
Pair programming and group remixing make reusability tangible: students drag functions into new contexts and see instant updates. Hands-on testing reveals efficiency, like fewer blocks for the same actions. Class galleries encourage justification discussions, turning abstract benefits into shared discoveries.
When should students create a new function instead of sequential code?
Use functions for any action repeated twice or more, or complex steps used once but potentially reused. Guide with side-by-side programs: repetitive versus modular. Students justify via block counts and edit ease during challenges.