- 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)
- Understand the problem
- Restate the problem in your own words.
- Know what the desired inputs and outputs are.
- 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).
- Break the problem down
- Into a few large pieces.
- Write down, either on paper or as comments in a file.
- Break complicated pieces down into smaller pieces.
- Keep doing this until all of the pieces are small.
- Code one small piece at a time.
- Think about how to implement it.
- Write the code.
- 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.
- Experiment
- Write a simpler version
- Make sure it works
- Make sure you understand it
- Modify it to make it more complicated
- Repeat until finished