Skip to content

Teaching Chapter V

Daniel Budd edited this page Apr 11, 2026 · 1 revision

Teaching Notes: Chapter V, Similarity with Functions

Teacher-facing notes for running Chapter V in class.

At a glance

Sections 21 (2 tutorials, 19 exercises)
Estimated time 3 weeks for a mixed-ability Year 9 class (12 to 15 lessons)
Prerequisites Chapters I through IV. Students need comfort with variables, loops, and conditionals.
Live chapter dbbudd.github.io/05.html

Students leave able to: define and call functions with parameters, reason about similarity as "same shape, different size via a scale factor", compose multiple function calls to build complex figures, and position shapes on a canvas using coordinate arithmetic.

What this chapter teaches

The mathematics. Similarity and scale. Two shapes are similar if one is a dilation (uniform scaling) of the other; the ratio of corresponding sides is the scale factor. Dilation and proportional change: if you scale every linear dimension by k, the area scales by . Coordinate positioning: placing a shape at (x, y) by passing the position as a function parameter. The classic flag proportions of countries around the world, chosen because they're a natural fit for parameterised shapes.

The programming. Functions. func name(param: Type) -> ReturnType { body }. Parameters and argument labels. The idea that a function is a named, reusable block of code that takes inputs and may return an output. Calling the same function multiple times with different arguments. Default parameter values. Function composition: calling multiple functions from a main routine to build a scene.

Why the sequence matters

Chapter V is the second longest (21 sections) and the most content-dense after Chapter II. It's also where the programming takes a big step up. Functions are abstract, and students need a lot of concrete examples before the abstraction sinks in.

Section 1 (Creating Functions) is the tutorial. Introduces func with a no-parameter example: a function that draws a specific octagon. Students see the syntax and call the function once. Keep it simple.

Section 2 (Octagons) is immediate application: draw several octagons using the function. The function is reusable; you call it wherever you want one.

Section 3 (Parameters) is the second tutorial. Adds a size parameter to the octagon function. Now calling drawOctagon(side: 50) draws a small one; drawOctagon(side: 150) draws a big one. This is the a-ha moment: the same function can do different things depending on what you pass in.

Sections 4 and 5 (Different Sizes, Different Shapes) are drill: call the parameterised function with different arguments to produce different outputs.

Sections 6 to 16 (the flags) are the core of the chapter. Students build functions for the flags of Denmark, Sweden, Norway, St Andrew, St Patrick, St George, Union Jack, Filled Star, Australia, Netherlands, France. Each flag is a new exercise where the student writes (or extends) a function to draw a specific national flag. The progression is deliberate: the simpler flags come first (solid stripes), the more complex ones later (unions, stars, saltires). The Union Jack is particularly fun because it composes three smaller flag functions (St Andrew, St Patrick, St George).

Sections 17 to 21 (Positions, Switzerland, Tonga, Puerto Rico, United States) introduce positional arguments. Functions now take an at: Point parameter to place the shape anywhere on the canvas. This unlocks Chapter VI.

The one thing every student should leave with

The idea that a function with parameters is a reusable template for a shape. Students who leave Chapter V able to write func drawStar(size: Double, at: Point) and use it three times with different sizes and positions have the foundation for every composite figure in Chapter VI. Every part of Chapter VI is just "call a function, then call another function, then another".

The mathematical corollary: similarity is what happens when you call the same function with a different size parameter. The function is the shape template; the size parameter is the scale factor. Two calls to the same function produce two similar figures. This is the most direct mapping between programming and geometry in the whole curriculum.

Common misconceptions

"I define the function once, then it runs automatically"

Students sometimes write a function definition and expect it to draw. Nothing happens. The function is defined but never called.

Fix: in the Creating Functions tutorial, make the distinction between defining and calling extremely explicit. Say "writing func drawSquare() { ... } tells Swift what a drawSquare is. Writing drawSquare() tells Swift to actually do it. You need both."

"A parameter and an argument are the same thing"

Parameters are declared in the function definition. Arguments are passed at the call site. Students mix up the names.

Fix: the Parameters tutorial uses both words. Reinforce them: "when you define the function, you give it a parameter. When you call the function, you give it an argument. Same idea, different name depending on whether you're writing the template or using it."

"Argument labels are optional"

Swift allows func drawStar(size: Double) and the call site uses drawStar(size: 100). The label size: is mandatory at the call site by default. Students sometimes try to omit it.

Fix: explain that the label is part of the function's signature and it's what makes Swift code read like English. drawStar(size: 100) is more readable than drawStar(100). Swift's opinion, not yours. Don't fight it.

"Changing a variable inside a function changes it outside"

This is a deep misconception about scope that some students will have. In Swift, value types (like Int, Double, String) are copied when passed to a function. Modifying the parameter inside the function doesn't affect the caller's variable.

Fix: if a student hits this, demonstrate on the board. Write a function that tries to modify its parameter, then show that the original is unchanged. This is one of the moments where "the variable is a copy" clicks.

"Similarity is about shape, not size"

Students often get similarity and congruence muddled. Similar shapes have the same angles and their sides are in the same ratio, but they can be different sizes. Congruent shapes have everything the same, including size.

Fix: when you reach section 4 or 5 (Different Sizes, Different Shapes), make the explicit link: "you just called the same function three times with three different size arguments. You got three shapes that have the same corner angles but different side lengths. That's similarity. The scale factor is the ratio of the side lengths."

Teaching moves specific to this chapter

The "make one, then make ten" drill

Before introducing parameters, have students draw one octagon by hand (without a function). Then draw ten octagons of the same size. They'll complain about copy-paste. Then introduce the function: write the octagon-drawing code once, then call it ten times. Drop the parameter in. Then ask for ten octagons of different sizes.The pain-then-relief structure is the same as the variables introduction in Chapter II. It works.

Flag-of-the-day

For sections 6 to 16, pick one flag per lesson and make it the "flag of the day". Before students write any code, show them the real flag (projector, just a photo), talk briefly about its history and what the colours represent, then measure its proportions. This gives every lesson a context and breaks up the repetitive "call a function, get a flag" loop.

The Union Jack reveal

Section 12 (Union Jack) is a highlight moment. It composes three flags (St Andrew, St Patrick, St George) into one. Before showing the Union Jack code, ask students to guess how it's built. Let them try and fail for 5 minutes. Then reveal that it's three function calls. The satisfaction is real.

Coordinate arithmetic introduction (section 17)

The Positions section is where things get harder. Up to now, every shape has been drawn at the origin. Now students pass a position parameter and place shapes anywhere. This requires thinking about (x, y) coordinates explicitly.

Use a whiteboard grid. Place three shapes at three different coordinates. Have students read the coordinates off the board before writing them in code. Make it physical.

The hardest section

Section 13: Filled Star. This one is deceptively tricky because students have to compose a function call with a fill colour and a position in one line, and the star polygon geometry is new. The {5/2} star has to be closed with closePath or similar so the fill has a bounded region. Many students' first attempts either don't close the shape (no fill) or have the fill leak outside the star (wrong polygon).

Honourable mention: Section 12 (Union Jack), which is conceptually harder because it requires calling three functions in the correct order and layering the results. Most students will need direct instruction on this one.

How to teach Filled Star: break it into three steps. First, draw the outline of a five-point star without fill. Second, add the fill colour and notice that it leaks. Third, add the closePath (or whatever the Pen API's equivalent is) and see the fill contained. Three small victories, one combined victory.

Extensions for fast finishers

  • More flags. The curriculum covers 11 flags explicitly. There are 193 UN member states. Pick any flag not in the curriculum and challenge students to reproduce it. Germany, Japan, Italy, Canada, Brazil, and South Africa are all doable with Chapter V techniques.
  • An animated flag. Use Input(decimal:id:) to vary the size or position in real time. The student drags a slider and the flag resizes or moves.
  • Recursive function. A function that calls itself. Students who get this far are ready for fractals. This is a preview of what a bonus lesson on recursion would cover.
  • A symmetry-checking function. Write a function that takes a shape definition and returns whether it has a line of symmetry. Hard but rewarding.

Things to say out loud

When introducing functions (section 1):

"You've been writing the same lines of code in different exercises. There's a better way. A function is a named block of code you write once and call many times. Let me show you."

When introducing parameters (section 3):

"A function without parameters always does the same thing. That's useful, but limited. A function with parameters can do different things depending on what you pass in. Watch: I'll add a size parameter to drawOctagon, and now the same function can draw a small octagon or a big one."

When explaining similarity (section 4 or 5):

"You just called the same function with three different size arguments. Look at the three shapes. Same corners. Same number of sides. Different sizes. They're similar. Similarity means 'same shape, different size'. The function is the shape; the size parameter is the scale factor."

When introducing the Union Jack (section 12):

"The Union Jack is not one flag. It's three flags stacked on top of each other: the red cross of St George for England, the white diagonal of St Andrew for Scotland, and the red diagonal of St Patrick for Ireland. You've already written functions for each of those. Today you call them all from one main routine and watch them layer up."

When introducing positions (section 17):

"Up to now, every shape you drew started at the origin. That was convenient, but limiting. From today, your functions take a position argument: an (x, y) coordinate that tells the function where to start drawing. This is how you place three shapes in three different places on the same canvas. It's also how Chapter VI works."

Things I learned when I taught this

Fill this section in after your first classroom run.

Links

Clone this wiki locally