Download - A High-Level Model For Software Development
![Page 1: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/1.jpg)
James Tam
A High-Level Model For Software Development
What is involved in the process of designing, writing and maintaining computer programs?
What are some ways that an algorithm can be specified?
![Page 2: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/2.jpg)
James Tam
What Is Computer Science?
Review: Solving problems with the computer
![Page 3: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/3.jpg)
James Tam
A Model For Creating Computer Software
Specify the problem
Determine how to solve the problem
Implement the solution
Maintenance of the solution
![Page 4: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/4.jpg)
James Tam
Specifying The Problem
Determine what problem will be solved by the computer
Verify the problem
![Page 5: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/5.jpg)
James Tam
Determine How To Solve The Problem
Specify the algorithm- Can be done in many ways
- e.g., flowcharts, spreadsheets (more to come later in this section of notes)
- Implementation independent!
Check the algorithm
![Page 6: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/6.jpg)
James Tam
Implement The Design
Translating the high level algorithm to an actual programming language (e.g., Pascal)
Test the program
This step is covered in the balance of this course (and the next course, CPSC 233)
![Page 7: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/7.jpg)
James Tam
Maintaining The Design
Modify the program according to changing needs and to address problems (software bugs)
Includes the application of techniques for good design (Software Engineering).
Some in CPSC 233 (more in CPSC 333)
![Page 8: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/8.jpg)
James Tam
What You Now Know: A Model For Creating Computer Software
Specify the problem
Determine how to solve the problem (algorithm)
Implement the solution
Maintenance of the solution
![Page 9: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/9.jpg)
James Tam
What Is An Algorithm?
The steps needed to solve a problem
Characteristics• Specific• Unambiguous• Language independent
![Page 10: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/10.jpg)
James Tam
Ways Of Specifying The Algorithm
Pseudo-code
Flowcharts
![Page 11: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/11.jpg)
James Tam
Pseudo-Code
Employs 'programming-like' statements to depict the algorithm
No standard format (language independent)
![Page 12: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/12.jpg)
James Tam
Pseudo-Code Statements
DisplayEnterActionDecision makingRepetition
Statements are carried out in orderExample: Calling up a friend1) Look up telephone number2) Punch in telephone number3) Wait for someone to answer : :
![Page 13: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/13.jpg)
James Tam
Variables
Are used with pseudo-code statements
Symbols (typically an alphabetic string e.g,, x, num, num1) used to store values
The value stored can change during the algorithm
![Page 14: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/14.jpg)
James Tam
Constants
Are used with pseudo-code statements
They are values that cannot be changed
![Page 15: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/15.jpg)
James Tam
Display
Used to show information
General format:
Line of text: Display 'Message'
Variable: Display Name of variable
Mixed display: Separate each item to be displayed with a comma
Example
Display 'Available credit limit $', limit
![Page 16: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/16.jpg)
James Tam
Enter
Used to get information
Information is stored in a variable
General format:
Enter: Name of variable
Example:
Enter userName
![Page 17: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/17.jpg)
James Tam
Pseudo-Code: Action
For computer programs it's usually an assignment statement (sets a variable to some value)
General form:Variable = arithmetic expression
Example:x = 2x = x + 1a = b * c
![Page 18: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/18.jpg)
James Tam
Pseudo-Code: Decision Making
If-then General form: if (condition is met) then statement(s)
Example: if temperature < 0 then wear a jacket
If-then-else General form: if (condition is met) then statement(s) else statements(s)
![Page 19: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/19.jpg)
James Tam
Pseudo-Code: Decision Making (2) Example: if (at work) then Dress formally else Dress casually
![Page 20: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/20.jpg)
James Tam
Pseudo-Code: Decision Making (3)
Types of conditions Symbol
Greater than >
Greater than or equal to ≥
Less than <
Less than or equal to ≤
Equal to =
Not equal to ≠
![Page 21: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/21.jpg)
James Tam
Pseudo-Code: Repetition
repeat-until
while-do
![Page 22: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/22.jpg)
James Tam
Pseudo-Code: Repetition (2)
repeat-until Repeat at least once (check if condition is met after statement(s)) General form: repeat statement(s) until (condition is met)
Example: repeat Go up to buffet table until full
![Page 23: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/23.jpg)
James Tam
Pseudo-Code: Repetition (3)
while-do Repeat zero or more times (check if condition is met before statement(s)) General form: while (condition is met) do statement(s)
Example: while students ask questions do Answer questions
![Page 24: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/24.jpg)
James Tam
Pseudo-Code: Fast Food Example
Use pseudo-code to specify the algorithm for a person who ordering food at a fast food restaurant. At the food counter, the person can either order or not order the following items: a burger, fries and a drink. After placing her order the person then goes to the cashier.
![Page 25: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/25.jpg)
James Tam
Pseudo-Code: Fast Food Example
Approach counter
If want burger then
Order burger
If want fries then
Order fries
If want drink then
Order drink
Pay cashier
![Page 26: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/26.jpg)
James Tam
Pseudo-Code: Grade Tabulator Example
Use pseudo-code to specify the algorithm for a grade tabulation program. The program will ask the instructor to enter in a percentage value for each student. Based on this value the program will determine if the student passed the course or not:
• If the percentage is 50% or greater then the student passed the course and the message 'Student receives course credit' will appear.
• Otherwise, if the percentage is below 50%, then the student failed the course and the message 'Student will not receive course credit' will appear.
As the instructor is entering grades, the program will automatically track the number of students who passed the course and the number of students that did not. The instructor indicates to the program that she has finished entering the grades by entering negative percentage (e.g., -1%) at which time the program displays the total number of students that passed and total that did not pass and it then ends execution.
![Page 27: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/27.jpg)
James Tam
Pseudo-Code: Grade Tabulator Examplepass = 0fail = 0
Display 'Enter percentage for student (negative percentage to end): 'Enter percentageWhile Percentage ≥ 0 do
If (percentage ≥ 50) thenDisplay 'Student receives course credit'pass = pass + 1
ElseDisplay 'Student will not receive course credit'fail = fail + 1
Display 'Enter percentage for student (negative percentage to end): 'Enter percentage
Display 'Number of students that passed: ', passDisplay 'Number of students that failed: ', fail
![Page 28: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/28.jpg)
James Tam
Summary Of Pseudo-Code Statements
Statement Purpose
Display Display informationEnter Get informationAction Perform an activity (not covered by the other statements)Decision Choose between different alternativesRepetition Perform a step multiple times
Variables are used in conjunction with these statements to store information.
Constants may be used to represent a value that does not ever change.
![Page 29: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/29.jpg)
James Tam
Basic Flowchart Elements
Action
Input
Decision
Off page Connector
Terminator
c
Arrow
Output
Variables and constants
![Page 30: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/30.jpg)
James Tam
Flowchart: Fast Food Example
Draw a flowchart to outline the algorithm for a person who ordering food at a fast food restaurant. At the food counter, the person can either order or not order the following items: a burger, fries and a drink. After placing her order the person then goes to the cashier.
![Page 31: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/31.jpg)
James Tam
Flowchart: Fast Food ExampleApproach
counter
Want
burger?
Want
fries?
Want
Drink?
Pay
cashier
Order burger
Y
Order fries
Y
Order drink
Y
N
N
N
![Page 32: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/32.jpg)
James Tam
Flowchart: Grade Tabulator Example
Use a flowchart to specify the algorithm for a grade tabulation program. The program will ask the instructor to enter in a percentage value for each student. Based on this value the program will determine if the student passed the course or not:
• If the percentage is 50% or greater then the student passed the course and the message 'Student receives course credit' will appear.
• Otherwise, if the percentage is below 50%, then the student failed the course and the message 'Student will not receive course credit' will appear.
As the instructor is entering grades, the program will automatically track the number of students who passed the course and the number of students that did not. The instructor indicates to the program that she has finished entering the grades by entering negative percentage (e.g., -1%) at which time the program displays the total number of students that passed and total that did not pass and it then ends execution.
![Page 33: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/33.jpg)
James Tam
Flowchart: Grade Tabulator Example
Begin
pass = 0
fail = 0
1
Percentage
'Enter percentage for student (negative to end'): '
![Page 34: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/34.jpg)
James Tam
Flowchart: Grade Tabulator Example (2)
2
1
Percentage ≥ 0?
3
Y
N
6
Percentage ≥ 50? N
Y
4
![Page 35: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/35.jpg)
James Tam
Flowchart: Grade Tabulator Example (3)
3
'Student will not receive course credit'
5
fail = fail + 1
![Page 36: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/36.jpg)
James Tam
Flowchart: Grade Tabulator Example (4)
4
'Student receives course credit'
5
pass = pass + 1
![Page 37: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/37.jpg)
James Tam
Flowchart: Grade Tabulator Example (5)
5
6
Percentage
'Enter percentage for student (negative to end'): '
![Page 38: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/38.jpg)
James Tam
Flowchart: Grade Tabulator Example (6)
'Number of students that passed: ', pass
'Number of students that failed: ', fail
End
2
![Page 39: A High-Level Model For Software Development](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816849550346895dde37b1/html5/thumbnails/39.jpg)
James Tam
Summary
What are the major steps involved in creating software• Specification• Design• Implementation• Maintenance
How to layout out an algorithm using flowcharts and pseudo-code
What are the basic elements of algorithms• Input• Output• Decision-Making• Repetition• Action• Variables and constants