This lesson presents a top-down problem-solving strategy for designing solutions to programming problems. The students will use a worksheet to learn about top-down design, and then, on paper, design a solution to a new turtle drawing challenge. Having practiced this approach on paper and in code, the students will be re-presented with the 3x3 square challenge from an earlier lesson and asked to improve upon their old solution by designing multiple layers of actions.



Students will be able to:


The main purpose here is to familiarize the students with the concept of developing "procedural abstractions." One of the main learning objectives in the CSP framework is: "2.2.1 Develop an abstraction when writing a program..." Furthermore the AP Performance Task: Create requires the students to "develop an abstraction to manage complexity of [their] program." For all intents and purposes, developing abstractions starts with writing reusable functions (or procedures) in their code that encapsulate and give a name to multi-line segments of code that other parts of their code calls upon.

A technique for deciding what functions someone should write is to look at the problem with a "top-down design" perspective. The process of creating software begins long before the first lines of code are written. Breaking a problem down into layers of sub-tasks, and writing well-named functions that solve those tasks is a creative act of abstraction. It also leads to good code that is more efficient, easier to read, and therefore easier to debug when problems arise.

In professional settings, teams of people first identify the problems and sub-problems the particular software will be addressing and how it will be used. This approach to designing software is critical when facing large-scale programming tasks. Once the problem is well understood, it can be broken into parts that teams or individual programmers can begin to work on solving at the same time. Full software systems take advantage of the power of abstraction; each programmer in a team can write code, assuming the subproblems will be solved and written by other teammates.


Teacher's Tip

We have prepared the same documents in different file formats for the lesson. The first file is in PDF format and has many graphic components. Another file is in .rtf format and is a text only document. All the graphics in the first .pdf file are described in narrative manner.

Getting Started

What Does Efficiency Mean?

In the previous lesson the students wrote a program that used layers of actions (actions that called other actions) to get the turtle to draw a diamond-shaped figure. Imagine that someone has two programs that drew the diamond-shaped figure. One program uses actions as the students did in the previous lesson. The other doesn't use actions; it's just a long sequence of the turtle's primitive commands. Discuss with the students which program is more efficient. Make an argument for why one is more efficient than the other. "Efficient" can mean several different things here:

Efficiency is an interesting thing to think about, but actions also introduce the ability to leverage the power of abstraction: when someone writes an action, it solves a small piece of a bigger problem. Having the small problem solved allows that person to ignore its details and focus on bigger problems or tasks. Today the students will get more practice with thinking about how to break problems down into useful actions.

Activity: Starting with a Worksheet



Activity: Coding Challenge

Challenge 12: Draw an "antenna" shape

Radio Antena

They should have already worked with a partner to break down the design above (the shape of the antenna from the worksheet) into its multiple layers of actions. Now they will have an opportunity to program their solution. Here are a few things to keep in mind:

Student Instructions

Start the turtle at (5, 4), then try to draw an antenna shape in the IDE below.

Quorum Turtle Module: Challenge 12

The following lines should be showing (with the unique order determined by their code):

Challenge 13: Draw 3 x 3 grid

The students are going to revisit a familiar problem, drawing the 3x3 square as efficiently as possible. The only difference is that this time they are armed with the ability to create layers of functions to help them design more elegant and efficient solutions. Use the techniques that they have learned for breaking down problems into layers of functions in order to improve upon their previous solution.

Student Instructions

3x3 grid

Start the turtle at (0, 0). Then try to draw the 3x3 grid using layers of actions.

Quorum Turtle Module: Challenge 13

The turtle will start at location (0, 0), facing up. The following lines should be showing (with the unique order determined by their code):


It's very possible that in writing a solution with actions, the turtle might actually execute more primitive operations than in the their previous version. That's OK, because the code should be much shorter and much easier to read. The students can trade a well-designed, well-written program for a clumsy, hard-to-read program at the cost of a few primitive operations.

Activity: AP Practice - Performance Task Response

Top-down design is design process and strategy for breaking down complex things. The AP Create Performance task asks students to write about their development process when writing code. Let's take a minute to understand this writing prompt and how it is scored. Here is the actual writing prompt 2b from the AP Create Task guidelines:

2b. Describe the incremental and iterative development process of your program, focusing on two distinct points in that process. Describe the difficulties and/or opportunities you encountered and how they were resolved or incorporated. In your description clearly indicate whether the development described was collaborative or independent. At least one of these points must refer to independent program development. (Must not exceed 200 words)

The students' responses to this prompt can get up to 2 points, and are scored looking at two major things:

  1. (1 point) Do they describe a real iterative process for writing the whole program - "Incremental and iterative" means that they continuously improved their program based on testing, reflection, or feedback from a partner.
  2. (1 point) Do they actually describe two points in time while writing your code, what the specific issue was, and how they got past it by reflecting or incorporating feedback from a collaborative partner.

Time for the students to try it

Ask the students to try to write a response to this AP Prompt thinking about either how they developed the idea for the antenna drawing program, or how they resolved to make the 3x3 grid program. They might have to use a little bit of imagination to assume that it's part of a larger program that they created themselves. The point is to practice writing about their development process. NOTE: Writing a response like this will take some time to think about and compose.

Wrap Up

Some points about actions and abstraction:

When we layer actions - with actions that call other actions - we are creating layers of abstraction. In programming, writing actions helps us create layers of abstraction that allow us to design and create increasingly complex systems. We've seen layers of abstraction before in the design of Internet protocols, or in the binary encoding of information. Solving a fundamental piece of a problem that can be reliably reused in a different context frees us to think about more complex problems because we can trust the piece that has been solved and don't have to worry about its details. Solving small problems - like how to send a single bit from one place to another - allows us to think about bigger problems, like sending numbers, or text, or images.

Discussion: "Where else in your life have you seen layers of abstraction? Connect the idea of layers of abstraction to some other activity."

There are many possible connections to make since almost any task in life can be broken down ad-infinitum. In the video about actions from the previous lesson, Chris Bosh makes a connection to basketball. Once someone know how to dribble and shoot, then that person learns some moves to do, and once that person know that, that person will run plays that rely on the fact that those fundamental elements (or the problems) have been solved.


Assessing Programs: On "antenna" or "3x3 grid" program

Question 1

Consider the figure below. Use top-down thinking to design a solution to the problem. In the space provided write a list of just the names of the functions that you would write in a program that draws this figure. (Assume that the long line segments are 6 turtle moves long.)

The shape below is the product of the turtle moving and drawing the lines in the following manner: The turtle starts at (0, 0). It moves to the right to position (5, 0), then moves up to position (5, 1). It moves to the left to position (0, 1), then moves up to position (0, 2). It moves to the right to position (5, 2), then moves up to position (5, 3). It moves to the left to position (0, 3), then moves up to position (0, 4). Finally, it moves to the right to position (5, 4) and stops.


Question 2 - Multiple Choice: Which of the following statements about writing actions and Top-Down Design is NOT true?

Question 3

In the Create Performance Task the students will be asked to identify an abstraction in their program and explain how it helps manage the complexity of the program. Functions are a form of abstraction. Pick a function they wrote in their solution to the 3x3 square problem and explain how it helps manage the complexity of their program.

Standards Alignment