Coding · Grade 9
Functions and Modular Design
Using a fictional fitness-tracker app, learners trace calls between functions with the call stack, control scope by passing parameters and returning results instead of using globals, write precise contracts with preconditions and postconditions, and separate pure functions from side effects. They then design programs top-down, build them bottom-up and plan a modular program in a reviewed design task.
- 4 lessons
- About 90 minutes
- Check what you learned: 8 questions
- Ways to answer: choose an answer, put code in order, trace code, match pairs, sort into groups and true or false
What learners will discover
- Define functions with parameters and return values, and trace nested calls using the call stack.
- Explain local and global scope and design functions that communicate through parameters and return values.
- Write function contracts with preconditions and postconditions, and distinguish pure functions from functions with side effects.
- Design programs top-down as single-responsibility functions and remove duplication with helpers.
Lessons
-
Functions and the flow of calls 6 steps3 practiceabout 22 min
-
Scope 5 steps3 practiceabout 20 min
-
Contracts and pure functions 5 steps3 practiceabout 20 min
-
Top-down modular design 5 steps3 practiceabout 20 min
-
Check what you learned 8 questions at the end
Keep exploring
More 9th grade coding
- 9th Grade Coding Worksheets10 printable worksheets
Guide for grown-ups
- How to start homeschooling: a step-by-step guide for familiesA guide for parents · 7 min read