1 / 16

The Construction of Programs

The Construction of Programs. CSC 145. Programming in the Small vs. Programming in the Large. Working alone vs. group of programmers Need for good design & planning Software Engineering. Program Development Process. Requirements analysis & specs Design Phase

giulia
Download Presentation

The Construction of Programs

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Construction of Programs CSC 145

  2. Programming in the Small vs. Programming in the Large • Working alone vs. group of programmers • Need for good design & planning • Software Engineering

  3. Program Development Process • Requirements analysis & specs • Design Phase • Implementation Phase (produce code) • Test & Installation • Operation & Maintenance

  4. Algorithm Development • Use of a natural language – pseudocode • Use of pictures & symbols (flowcharts)

  5. Example: Algorithm to add the integers 1 through 100 in natural language (pseudocode) Set Sum to 0 & counter Ct to 1 Repeat following two steps until Ct is greater than 100 Add Ct to the Sum saving result in Sum Increase Ct by 1 Output Sum of the 100 numbers

  6. Example: same algorithm in Ada Sum := 0; Ct := 1; While Ct <= 100 loop Sum := Sum + Ct; Ct := Ct + 1; End loop; Put (Sum);

  7. Algorithms will usually be expressed using 3 Controls: • Sequence – series of steps executed in sequential order • Selection – one of two or more alternatives are chosen • Iteration – repeating a certain number of times or until a certain condition is met

  8. Sequence • Get number of hours worked • Get hourly rate of pay • Compute Salary by Number of hours X Hourly Rate

  9. Selection If Count is zero then output “Sorry”, otherwise Compute Average by dividing Sum by Count

  10. Iteration Keep adding 1 tbsp.sugar and tasting until sweet enough

  11. Problem Solving using a computer • Specify the problem (make sure you understand it) • Design algorithm to solve problem • Express algorithm as code in programming language • Compile & Run program on the computer

  12. Stages of a Working Program • Source Code is created using text editor. • Compiler translates into object module. • Linker puts object modules together (builds) to create load module. • Operating System puts load module in memory and executes.

  13. When Problems get complicated Divide & Conquer!! Top-Down Design

  14. Top-Down Design (stepwise refinement) See Example Handout…note that as you move from Top to Bottom the steps are being refined into simpler tasks.

  15. Program Structure in Ada With …; Use …; Procedure programname is any declarations (including variables) Begin executable statements End programname;

  16. Example: Simple Ada program With TEXT_IO; Use TEXT_IO; Procedure First is; Begin Put (“This is my first program…whoopee!”); End First;

More Related