Students will be able to...
- Build custom SNAP blocks that take arguments
- Do Now 3.3: Jumping
- Lab 3.3 handout (Let Me Check My Calendar) (Download in Word) (Link to PDF)
Duration | Description |
---|---|
5 minutes | Welcome, attendance, bell work, announcements |
15 minutes | Lecture and introduce activity |
20 minutes | Custom block argument activity |
15 minutes | Debrief and wrap-up |
- Lecture
- Introduce block arguments
- Ask students to speculate on risks of relying on variables instead of arguments
- Variables could be changed by code other than the custom block, variable names could be changed causing errors, etc.
- Emphasize importance of custom blocks being self-contained
- Custom blocks should continue to function correctly independent of any other changes in the program
- Custom blocks should work correctly anywhere in the program and not require specific setup or cleanup
- Point out how frustrating code would be if blocks like required setting a variable with a specific name to work
- Ask students to speculate on risks of relying on variables instead of arguments
- Demonstrate declaration and usage of arguments
- Point out that arguments are very similar to script variables, except their values come outside the block
- Explain argument types
- Only discuss text, numbers, and Booleans
- Other types can be mentioned, but won't be used in the course
- Ask students to describe why restricting types is important
- Only discuss text, numbers, and Booleans
- Point out that arguments are passed by value
- Specifically, changing the value of an argument inside a custom block will typically NOT change the value at the call site
- Arguments example
- Basic argument in pen category
- Pass by value example in "Variables" category
- Introduce block arguments
- Activity
- Students should complete the "Let Me Check My Calendar" activity individually or in pairs
- This lab consists of a series of independent custom blocks. The blocks need not necessarily be completed in the order given, but are roughly in order of difficulty.
- The bonus (part 3.4) requires implementing a fairly complex formula.
- Students should complete the "Let Me Check My Calendar" activity individually or in pairs
- Debrief
- Ask a different student to provide their solution to each part.
- If time allows, discuss multiple solutions to each part.
- Emphasize differences and encourage discussion about advantages and disadvantages.
- Point out corner cases and cases where typed arguments are particularly helpful.
- For example, avoiding try to find out whether "bubblegum" is a leap year
- Part 3.4 is a fairly complex formula and should be a challenge for advanced students.
- Struggling students should focus on section 1. The problems in section 2 represent more complex algorithms, but not necessarily any more difficult usage of arguments.