Overview

Learning Objectives

Students will deepen their understanding of function definitions and the Design Recipe

Evidence Statements

Product Outcomes

Materials

Pens/pencils for students, fresh whiteboard markers for teachers

Class poster (List of rules, language table, course calendar)

Language Table (see below)

Student Workbook folders with names on covers, and something to write with

Preparation

Write Agenda on board

Display class posters, Language Table, Design Recipe

Seating arrangements: ideally clusters of desks/tables

In the previous unit, you reviewed almost everything from Bootstrap 1 including Datatypes, Contracts, and the Design Recipe. In this unit you will go above and beyond all that, and learn an entirely new datatype that will be the basis for everything you’ll do in Bootstrap 2. To make sure the material is fresh in your mind, tackle the following activity:

Ask a few introductory review questions to test students’ understanding, such as:

What are the three parts of a Contract?

What is the racket code to draw a solid, green triangle of size 22?

Why is it important to write at least 2 examples before defining a function?

Turn to Page 7 in your workbook. Write a function called

`double-radius`, which takes in a radius and a color. It produces an outlined circle of whatever color was passed in, whose radius is twice as big as the input.If walking through this example as a class, use a projector so kids can see the function being written on the computer:

Remember how to use the design recipe to work through word problems?

What is the Name of this function?

What is the Domain of this function?

What is the Range of this function?

What does it do? Write a Purpose Statement describing what the function does in plain English.

Review the purpose of Contracts: once we know the Name, Domain, and Range of a function, it’s easy to write EXAMPLEs using those datatypes.

Using only the Contract and Purpose Statement, see if you can answer the following questions:

Every Example begins with the name of the function. Where could you find the name of the function?

Every Example has to include sample inputs. Where could you find out how many inputs this function needs, and what types they are?

Every Example has to include an expression for what the function should do when given an input. Where could you look to find out what this function does?

Write two Examples on your paper, then circle and label what is changing between them. When labeling, think about what the changing things represent.

Your examples should look similar to:

Each one of these answers can be found in the Contract or Purpose Statement. Suggestion: Write these steps on the board, and draw arrows between them to highlight the process. The goal here is to get students into the habit of asking themselves these questions each time they write examples, and then using their own work from the previous step to find the answers.

- variables in the function definition. (You don’t always want to make a pink circle whose radius is double 50. You want to be able to change the color and radius.)Once you know what is changing between our two examples, you can define the function easily. The things that were circled and labeled in the two examples will be replaced with
Underneath your examples, copy everything that doesn’t change, and replace the changing things with the variable names you used.

Check students understanding: Why do we use variables in place of specific values? Why is it important to have descriptive variable names, as opposed to

`n`or`x`? Turn to Page 8 in your workbooks. Write a function called

`double-width`, which takes in a height and a color. The function produces a solid rectangle, which is whatever height and color were passed in. Its width is twice the height.- Fill out the Contract for this function.
What is the function’s Name?

What is the function’s Domain?

What is the function’s Range?

- Using the Contract you’ve written, write two Examples for the function.
What part of the Contract helps you fill in the left side of an Example?

What part of the Contract tells you what the function needs as input?

How can the Range of a function help you write the Example?

- Looking at those two examples, circle the parts that are change-able, then label them with a good variable name.
Why is it helpful to choose a variable name before defining the function?

Now write the function definition, using the Examples you’ve written.

This is very similar to the previous problem, and is meant to get students very comfortable with using the design recipe before delving into more complex problems. Remind students about nested functions: A function whose range is a number can be used inside of a function requiring a number in its domian, as in

`(circle (* 2 25) "solid" "red")`.