NOTE: As of December, site content associated with Google accounts has been blocked by the DCPS Technology system. For that reason, more up-to-date information can be found in my TEAMS channels for the remainder of the school year.
Warm Up (5 minutes)
Activity (30 minutes)
Wrap Up (10 minutes)
Parameter: a variable in a function definition. Used as a placeholder for values that will be passed through the function.
Argument: the value passed to the parameter
Return: used to return the flow of control to the point where the procedure (also known as a function) was called and to return the value of expression.
Return Total:
It stops the flow of the function. If a return is inside of a conditional, if that condition is met the function ends there.
It returns a value to the place where the function was called.
Extracting shared features to generalize functionality is known as procedural abstraction.
Using parameters allows the functions (also called procedures) to be generalized.
Using procedural abstraction helps improve code readability.
Procedural abstraction manages complexity by allowing for code reuse.
For example: the function move(id, direction) could be used to move an element in any direction, rather than writing separate functions for each direction.
Students use the knowledge and skills they've developed working with parameters and return values to develop a Rock Paper Scissors App. Unlike typical Make projects, students are given a significant portion of the starter code but are given three functions with parameters and return values that they'll need to develop themselves. At the end students submit their apps which can be assessed using a provided rubric.
Make lessons typically ask students to take on an entirely blank screen when writing their program. In this instance students have to take on the "blank function" which needs to fit within the larger program they're developing. This is part of a broader mindset shift that students develop in this unit. Functions with parameters and return values operate like their own "mini programs" which can be written and tested independently. There is actually less difference than students might think between previous make projects, in which students get the user interface elements and no code, and this project, in which they get some starter code but blank functions with parameters. In each case they need to develop programs that integrate into a larger portion of the project. The focus of this unit is how functions with parameters and return values help further split programs into logical chunks like this.
CSP Conceptual Framework
CRD-2 - Developers create and innovate using an iterative design process that is user-focused, that incorporates implementation/feedback cycles, and that leaves ample room for experimentation and risk-taking.
CRD-2.F - Design a program and its user interface.
CSTA K-12 Computer Science Standards (2017)
AP - Algorithms & Programming
2-AP-14 - Create procedures with parameters to organize code and make it easier to reuse.