0% found this document useful (0 votes)
9 views25 pages

CMPT 120: Topic: Software Development Process

notes

Uploaded by

Alex Wu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views25 pages

CMPT 120: Topic: Software Development Process

notes

Uploaded by

Alex Wu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

CMPT 120

Topic: Software Development Process


Last lecture
• Statements
4. Input statements
5. Operational statements –
String manipulation
6. Conditional statements We’ll see these
7. Iterative statements statements later!

• Expressions

2
In this lecture we shall cover
• Software development process (or workflow)
1. Houston! We have a problem
2. Design a solution
3. Implement the algorithm
4. Execute the program
5. Test the program
• Type of errors
• Let’s try!

3
Learning outcomes
At the end of this course, a student is expected to:
• Create (design) simple algorithms
• Create (design) small to medium size programs using
Python:
• Decompose a solution into parts
• Translate pseudocode to/from Python programs
• Use the core features of Python to design programs to
solve problems

4
Software Development Process
1. Is my Python
program
Execution
working?

6
Using Python
IDLE Program 2. Does it solve the
editor problem?
Step 1. Problem Statement
• Problem statement is the statement of a problem
(or task) we, software developers, are to solve
• Example:
• Problem: How much does our lunch cost?
• Problem Statement: Compute the cost of a lunch:
sandwich, juice and apple

6
Step 2. Designing our solution
• Our solution to the problem statement is an
algorithm, which we can express using either
• Natural languages like English
• Pseudocode
• Flowchart
• Drawings

• We may start with a high level version of the


algorithm, which we decompose into a low
level (detailed) version of the algorithm
7
Step 3. Implementing (Coding)
our Python program
• During implementation, we translate our low level
algorithm into a Python program using the Python
IDLE Program editor

8
Step 4. Executing our Python
program using an interpreter
• In this step, we execute our Python program,
i.e., the instructions of our Python program are
interpreted and executed (1 at a time) by the
Python interpreter

9
Interpreter vs Compiler
• An interpreter translates 1 programming
language statement at a time into machine
language instruction which the computer can
understand and execute
• A compiler translates an entire program into
machine language in one go and stores the
resulting machine language instructions into a
file called an executable
• Once the program has been compiled, we can
execute the executable file over and over again
• An interpreter and a compiler are both
software 10
• Python uses an interpreter, we say that Python is
an interpreted language
Step 4. Executing our Python
program using an interpreter
• Therefore, we answer the question:
1. Is my Python program working?
• If it runs then the answer is Yes -> Youpi! 
• If it does not run because there is an error, then
we need to fix the error and try to run our
Python program again

• What could go wrong? 11


Syntax Error
• Occurs when our Python code does not follow
the Python syntax rules
• Example:

• Looking at the software development process,


at which step would a syntax error be
detected?

• In which step(s) would we fix a syntax error?


12
Step 5. Testing our Python
program
• During testing, we answer the question:
2. Does it solve the problem?
• We answer this question by testing our Python
program using a variety of test cases, each using
either
• Good data
• Bad data
• Boundary data

13
• When testing, our goal is to “crash” our program
Test Case
• Test case contains
1. 1 particular set of data (either good, bad or
boundary)
2. Expected result, which must be computed
beforehand (before we start our testing)
• Before feeding the set of data to our program, we must
know what the result will be otherwise we will be unable
to ascertain whether our program works or not if we
simply

14
Let’s try to create test cases
for the problem: How much
does our lunch cost?
Test Case: Test Data Expected Results____

15
Observations about the
creation of test cases

16
Let’s try to create test cases for
our Assignment 1
Test Case: Test Data Expected Results____

17
Step 5. Testing our Python
program
• We test our Python program using 1 test case at
a time
• We feed the data of the test case into our
executing program
• We comparing its results (perhaps displayed on
the computer monitor screen) with the expected
results of the test case
• If both results are the same -> Youpi! 
• If they are not, then there is an error in our program
which we need to fix
• Once the error is fixed, we test our program again
18
with all the test cases we have used so far
• What could now go wrong?
Runtime Error
• Once all the statements in our Python program
follow Python syntax rules (no syntax errors), and
our program executes, it may be the case that
the data assigned to our variables are such that
an error occurs

• This type of errors is called runtime errors


because they occur at run time, when the
Python code runs

19
Runtime Error - Example
• Example:
>>> sum = 2635
>>> numberOfStudents = 0
>>> sum / numberOfStudents

Traceback (most recent call last):


File "<pyshell#2>", line 1, in <module>
sum/numberOfStudents
ZeroDivisionError: integer division or modulo by
zero

20
Runtime Error
• Looking at the software development process,
at which step would a runtime error be
detected?

• In which step(s) would we fix a runtime error?

21
Semantic Error
• Once all the statements in our Python program
follow Python syntax rules (no syntax errors) and
the code of our program is such that it guards
against potentially problematic situations
and/or data (no runtime errors), it may be the
case that the results we obtain are erroneous

• This is to say that our Python program does not


solve the problem!!!

22
Semantic Error
• Another way of saying this is that we did not
give the computer the correct instructions
• Remember: computers will do exactly what we tell
them to do
• Example of semantic error:

• Looking at the software development process,


at which step would a semantic error be
detected?
23
• In which step(s) would we fix a semantic error?
Observations about the S/W
development process
• When we develop software, we often iterate
(repeat) certain steps of the Software
Development process
• For example:

24
Let’s try this S/W
development process
• Problem Statement: Computing the class
average for a midterm examination (assuming
5 students wrote the midterm examination)

28
25

You might also like