Unit 3, Chapter 1, Lesson 4: Using Simple Commands
Students use the App Lab programming environment for the first time and become acquainted with the turtle. The chief problem is to find the most “efficient” way to draw an image of a 3×3 grid using a limited set of only 4 commands.
Students will be able to:
- Use App Lab to write programs that create simple drawings with “turtle graphics.”
- Create a program with a partner following the pair programming model
- Explain different ways one might measure the efficiency of a program.
- Pair Programming – A method of programming in which two programmers write code using a single computer. One programmer in the “driver” role uses the mouse and keyboard to actually write the code while a second acts as a “navigator”, keeping track of the big picture, catching errors, and making suggestions. Programmers switch roles frequently and communicate throughout the process.
- Turtle Programming – a classic method for learning programming with commands to control movement and drawing of an on-screen robot called a “turtle”. The turtle hearkens back to early implementations in which children programmed a physical robot whose dome-like shape was reminiscent of a turtle.
Getting Started–Transitioning to Programming
- Think back over the human machine language lessons we just completed. In your Word Online file for this class, write down some advice or encouragement you’d give to students in next year’s class before they complete those same lessons. What attitudes or skills will be important?
- Share your advice.
- SPOILER ALERT: This advice isn’t really for next year’s students, but for all of you! Today we’re going to begin programming on the computer, and while that’s obviously different from the human machine language activities we just completed, a lot will be the same. You’ll need to stick with it, pay attention to detail, and collaborate with others. In fact, before we jump in there’s one new collaboration skill I want to teach you all.
- Today we’ll be using a practice called pair programming. Pair progamming helps people make better programs by working together. The main idea is that two programmers use a single computer to collaboratively develop code. There’s a few rules to make sure this system works effectively.
- There is only one computer and two programmers.
- Assign one student “driver” and the other “navigator”. Don’t worry, you’ll switch often.
- The driver is the only one to touch the keyboard/mouse.
- The navigator should look for problems in the code and keep track of the high-level plan.
- Both driver and navigator should be communicating constantly by talking out loud and sharing ideas.
- Driver and navigator roles must switch when the teacher indicates, typically every 3-5 minutes
Activity–Move to App Lab
- Get with a partner
- To get you situated in App Lab there’s a quick video. Once everyone is through that we’ll get started. I’ll keep track of time and remind you to switch who is driver and navigator every 3 minutes or so. Make sure you’re ready to switch by talking out loud and sharing ideas.
- Show me your work in the answer viewer. I will be looking for the following criteria:
- The program draws the desired figure.
- The turtle is returned to its starting location and is pointed in the correct direction.
- The figure is located in the correct position, relative to the starting position of the turtle.
- The program only makes use of the “building block” commands provided.
- The program is reasonably efficient in its execution.
Wrap-up–What does “efficiency” mean when programming?
- Compare Solutions and Discuss: Each pair of students should get together with another pair to compare their solutions for each of the three problems to determine which is the most efficient. Once they have shared and compared their solutions they can consider the questions below.
- In your Word Online file for this class, respond to the following:
- What strategies or reasoning did you use to identify possible solutions?
- Is the solution that you or another group found the most efficient? How do you know?
- What is the “most efficient” way to program the solution for the 3×3 grid?
- Share at your tables.
- Today’s activity challenged us to find the most efficient solution to a problem. We care about efficiency when we don’t want to waste something valuable, like money, time, or space. We measured the efficiency of our programs in terms of lines of code, but there are other ways to think about efficiency when talking about code or programs that run on a computer. When we try to create efficient programs, what other valuable resources might we be concerned about conserving?
What’s the point? Why constrain to 4 commands
- Why did we constrain you to only working with 4 possible commands? We begin programming with only a few commands for a few main reasons:
- What you did today is what you always do when programming: use a language to express a solution to a problem. Collaborative problem-solving skills are important factors in programming. Being able to get together with other people to talk about and make reasoned arguments about the best ways to code things is what professionals do.
- Learning to program isn’t just a matter of memorizing commands. The art of programming – the creative part – is always about understanding how to use the features of a programming language to solve a problem.
- Whether you know 4 commands of a language or hundreds, you will always be constrained by the programming language. The reason you need to learn how to program is because there isn’t a command to do every little thing; you have to understand the set of things that a programming language can do, and then use your creativity and problem-solving skills to get the computer to do what you want.
- In this class, we will repeatedly run into the challenges we encountered today. Even seemingly simple problems will require us to creatively apply the tools we have available: the commands or instructions provided by the programming language.
- Multiple approaches are always possible to solve a problem. Furthermore, we may never be sure we have found the most efficient one. We may not even agree about how we should measure efficiency.
- As we saw today, even when designing programs using four commands to draw with a turtle, the solutions are not always easy. We will definitely need to keep practicing as we start tackling more complex challenges.