Day 6 (WC)


GOAL: Students will be able to…

  1. Break a large problem down into smaller pieces
  2. Write methods to solve each smaller problem
  3. Solve a complicated problem using Top Down Design
  4. Identify good and poor decomposition


  1. Break Down (Decompose)–Breaking down (decomposing) your code is splitting it into more functions.
  2. Read Like a Story–Programs that “Read like a story” have good decomposition and make the code easy to follow.
  3. Indentation–Indentation is the visual structure of how your code is laid out. It uses tabs to organize code into a hierarchy.
  4. Decomposition–Decomposition is breaking your program into smaller parts.
  5. Top Down Design–Top down design is a method for breaking our program down into smaller parts.


  1. REVIEW: 1.5.2 The Start Function Quiz
  2. Do the Decomposition Activity–Get the handout from your teacher
    1. Write the instructions for making a peanut butter and jelly sandwich
    2. Using a student volunteer, execute student instructions to make a sandwich as a computer would. Did it work the way you thought it would?
    3. You are not allowed to interpret what the instructions mean, only to execute the instructions literally.
  3. Watch: 1.6.1 Top Down Design and Decomposition in Karel
  4. Using the graphic organizer shown in the video, break down or decompose the process of making a PB & J. Notice how the process can be broken down into functions such as putIngredientOnKnife() or spreadTheIngredients().
  5. 1.6.3 Hurdle Karel
    1. Look at the example of exercise Hurdle Karel. Without running the program, predict what Karel will do and write the pseudocode:  1.6.3 Hurdle Karel
    2. Write your pseudocode on the board so that the class may follow it as the example is run.
    3. Run Hurdle Karel and compare your pseudocode to the actual result of the program. 1.6.3 Hurdle Karel
    4. What did you notice?
  6. 1.6.4 The Two Towers
    1. Notice the starting world and the result world of Karel.
    2. Identify the objective, the preconditions, postconditions.
    3. It might be helpful to move Karel to avenue (2, 1) so that you can see where Karel will begin when she begins to build the Tower.
    4. Once Karel is moved to (2, 1), write the first commands for the buildTower() function.
    5. Be sure to use good style in writing functions by indenting code and using proper syntax.
    6. Before getting with a partner to build the start function, you will need two helper functions.
    7. Once the buildTower() function is built as a class, break into pairs and begin to build the start function.
  7. If time permits:
    1. Decompose more complicated tasks from your every day life
    2. Decompose the same problem into multiple solutions with various levels of granularity
      1. For example, Making a PB&J could have the following answers
        1. Take bread and PB out of cabinet, take Jelly out of fridge, combine ingredients into sandwich
        2. Raise arm, Grasp cabinet handle, Pull handle to open door, etc… (this is probably more granular than you would like, but hopefully you understand the idea!)
  8. FYI: CodeHS Online Textbook–use this as a resource
  9. BEFORE YOU LEAVE, WRITE ABOUT THE FOLLOWING (respond to just 2 out of the following 7 questions) in the Word Online file named Web Apps & Coding for this class (you will write in this file daily):
    1. What did you learn in this lesson/day?
    2. How did you learn it?
    3. What was your “a-ha!” moment? What sparked it?
    4. When did you get stuck? How did you get “unstuck”?
    5. Why is it useful to be able to break down problems into smaller sub problems?
    6. Is this strategy only useful for programming? What other situations might we apply this method of problem solving to?
    7. Describe how you helped Karel break down a big problem into a smaller problem today. How did that affect how you wrote your code?

Leave a Reply

Your email address will not be published. Required fields are marked *