Skip to the content.

Functions and Modular Code

Main repository: https://github.com/ssis-aa/functions-and-modular-code (fork) and further cross-reference: https://sites.google.com/ssis.edu.vn/automation/

Overview

  1. Welcome to Advanced Automation!
  2. Introduction to Functions
  3. Shock Detector Case Study
  4. Mastery Check - Sketch of Functions
  5. Making Code Modular
  6. Module Maker - Creating modular code yourself!
  7. Drink Machine Part I
  8. Drink Machine Part II
  9. Drink Machine Testing Software

1 Welcome to Advanced Automation!

1-1 Why Automation?

YouTube Video - Although we hear about the negative sides of automation in today’s world, learning how to use automation ourselves is essential to seeing how it can be a force for good. In this first video of the automation course this year, I want to share some of the reasons why I am optimistic about what we are going to learn this year.

1-2 Building Automation

For this task, there are three tools you can explore how to build your own automated solutions to problems you face. You can choose any of them. Here are three videos describing how to build with each one:

Your task for the next class is to experiment with any of these tools to get a sense of how they work. Feel free to look for other tutorials out there to help you with any questions that might arise.

You must then build your own two automated tasks with any of the tools above. You should be prepared to explain the background context and the steps in the automation you build. Submit a single screenshot for each program in the assignment below.

1-3 Documenting and Decomposition

Template for decomposing an automated task

1-4 Assignment Automation (Schoology)

2 Introduction to Functions

2-1 Introduction to Functions

YouTube Explanation - Last week we started looking at ways to break tasks down into individual steps. This video formalizes this using the programming concept of a function. You’ll learn some vocabulary of functions and ways to describe them using inputs, outputs, and how they relate to each other through algorithms.

2-2 Functions Case Study: Gmail Auto-reply

YouTube Video - Using what I showed you in the last video, we take a look at code for my Gmail Auto-reply script and analyze functions for inputs, outputs, and algorithms. I show a few examples and leave the rest for you to do with your team. Along the way, we learn a bit about arrays, the logical OR operator, and some other elements of Javascript.

Template for Analysis - and assignment in Schoology

3 Shock Detector Case Study

3-1 Shock Detector Case Study

3-2 Accounts on Github and Replit

Accounts for Collaboration in Advanced Automation

4 Mastery Check - Sketch of Functions

4-1 Function Sketch Mastery Check

Following the style of what I did in the first video of breaking down the Shock Detector task, choose one of the problems mentioned in class and break it into a series of functions that each achieve a specific sub-task. For each function, identify the inputs and outputs to the extent that you can.

Template for students to copy and fill in ** Standard 3 formative

5 Making Code Modular

5-1 Making Code Modular W3-1

In this skill-building activity, you will follow along with the video below to convert a single program into modular code organized into functions

6 Module Maker - Creating modular code yourself!

6-1 Module maker - create code yourself ** standard 1 and 3 summative

Students create modular code and submit it. The code and description will be graded in the standards 1 and 3.

Task Description and Rubrics for Standards 1 and 3

7: Drink Machine Part I

7-1 Drink Machine Project

Review of global and local variables in https://makecode.microbit.org/ Example code: https://makecode.microbit.org/_PMgfmrJg31tw

8: Drink Machine Part II

Reflect on the 3 stages when making a cup of coffee:

8-2 Drink Machine - Sharing Stage 1 W4-3 standard 4

Students submit the code that generates two of the drinks from the list as assigned from class.

W4-3 Project 2 - Simulator Code

8-3 Drink Machine Level Up videos

Now that you’ve played with Drink Machine and have done some things the long way, Mr. Weinberg is showing the better ways than the wait times and further details:

9: Drink Machine Testing Software

9-1 Drink Machine Testing Software

Copy the code from the following link into your program. After pressing Button A it should generate a random drink.