• Take a break learning commands to talk about general approaches
  • Real computational tasks are complicated. To accomplish them you need to think before you code.

Problem decomposition steps (10 minutes)

  1. Understand the problem
    1. Restate the problem in your own words.
    2. Know what the desired inputs and outputs are.
    3. Ask questions for clarification (in class these questions might be to your instructor, but most of the time they will be asking either yourself or your collaborators).
  2. Break the problem down
    1. Into a few large pieces.
    2. Write down, either on paper or as comments in a file.
    3. Break complicated pieces down into smaller pieces.
    4. Keep doing this until all of the pieces are small.
  3. Code one small piece at a time.
    1. Think about how to implement it.
    2. Write the code.
    3. Test it on it’s own and fix any problems.

Exercises (15 minutes)

  • This week we will be working on more complex exercises
  • Show end result of first exercise
  • Take time now in class to understand and break down the problem
  • Spend 15 minutes working these first two steps
  • Only start coding if you’ve full understood and broken down the problem

Make a simpler version first (5 minutes)

If you aren’t sure how to do something, make a simpler version that you do know how to do first.

  1. Experiment
  2. Write a simpler version
  3. Make sure it works
  4. Make sure you understand it
  5. Modify it to make it more complicated
  6. Repeat until finished