Presentation is loading. Please wait.

Presentation is loading. Please wait.

Designing Programs.

Similar presentations


Presentation on theme: "Designing Programs."— Presentation transcript:

1 Designing Programs

2 Approach Until Now Pick smallest meaningful step you can do Goto 1
Do it Test it Goto 1

3 New Approach Can I do it in ~10 lines? Yes: Do it No:
Break the problem down into smaller tasks Define each in terms of input and output With each task, go to 1

4 Reasons For Functions Reuse code:

5 Reasons For Functions Create abstractions: Detailed Abstracted

6 When To Function Reusing same code in multiple locations
Want to provide abstraction Existing code is too complex

7 How To Function A good function Does exactly one job

8 How To Function A good function Does exactly one job
Has clear inputs/outputs

9 How To Function A good function Does exactly one job
Has clear inputs/outputs Is the right length Probably Not Maybe Sure

10 Comparison Monolithic vs Modular…

11 Stepwise Refinement Take problem Break into subproblems
With each subproblem: Can you implement it easily? Yes : Done No : Goto 1 with this problem

12 Building a Program Goal: Display month calendar given year, month

13 Break Down

14 Break Down

15 Break Down

16 Break Down

17 Break Down

18 Break Down

19 Break Down

20 Bottom Up Implement low level functions, test individually

21 Top Down Implement top level functions using stubs for lower level ones

22 Real World Development is cyclical Make plan Code to plan Learn stuff
Goto 1


Download ppt "Designing Programs."

Similar presentations


Ads by Google