Program Development Life Cycle: IGCSE Computer Science
Program Development Life Cycle: IGCSE Computer Science
Analysis Design
C7.1
Program
Development
Life Cycle
Coding Testing
Design Testing
Mini software that you will be doing in the exam (Taken from the specimen paper).
Scenario
Your task
Analysis
ANALYSIS
REQUIREMENT SPRECIFICATION
Is this what my
client want?
TWO STEPS OF
ANALYSIS
Decomposition Abstraction
DECOMPOSITION
Decomposition breaks down a complex problem into smaller parts, which
can be subdivided into even smaller parts, that can be solved easily.
Confirmation
Find a place Arranging
on who is
to hang out Transport
going
ABSTRACTION
Abstraction keeps the key elements required for the solution to
the problem and discards any unnecessary details and
information that is not required (temperorily).
LEVEL 1
ABSTRACTION - EXAMPLE 2 (TEACHING THIS LESSON)
LEVEL 2
ABSTRACTION - EXAMPLE 2 (TEACHING THIS LESSON)
LEVEL 3
AND SO
ON...
DESIGN
In this stage, the developers of the
program will continue the
decomposition phase from the analysis
and begin to draw up visuals of the end
product.
DESIGN
discovered during
development.
C7.2 - System,
sub-system
and Structured Diagram
Computer system
• Made up of software, data, hardware,
communications and people.
• Each computer system can be
divided up into a set of sub-systems
• Each sub-systems can be further
divided into sub-systems and so on
until each sub-system just performs
a single action.
Computer system
Example
• Made up of software,
data, hardware,
communications and
people.
• Each computer system
can be divided up into a
set of sub-systems
• Each sub-systems can be
further divided into sub-
systems and so on until
each sub-system just
performs a single
action.
Computer system Example
• Made up of software,
data, hardware,
communications and
people.
• Each computer system
can be divided up into a • Software - the code
set of sub-systems • Data - users' preference (like and
• Each sub-systems can be follow)
further divided into sub-
• Hardware - server to store all the
systems and so on until
data (posts, stories, etc)
each sub-system just
performs a single
• Communication and people -
action. instagram's employees
Computer system Example
• Made up of software,
data, hardware,
communications and
people.
• Each computer system
can be divided up into a
set of sub-systems
• Each sub-systems can be
further divided into sub-
systems and so on until
each sub-system just
performs a single
action.
post story reel
Computer system
Normal
• Made up of software,
data, hardware,
communications and
people.
• Each computer system
can be divided up into a
set of sub-systems
• Each sub-systems can be
further divided into sub-
systems and so on until story
each sub-system just Close
performs a single friends
action.
Other examples of a
computer system
• Alarm App
• Weather App
• Games!!
to aspiring programmer
Top-down design
Decomposition of a computer system into a set of sub- systems, then
breaking each sub-system down into a set of smaller sub-systems,
until each sub-system just performs a single action.
Structured diagram in application
(alarm clock)
Alarm Clock
Structured diagram in application
(alarm clock)
Alarm Clock
Inputs Outputs
Processes
Structured diagram in application
(alarm clock)
Alarm Clock
Inputs Outputs
Processes
Set Time
Turn alarm
Check Time Sound Turn off
on and off
Alarm alarm
Try it yourself
A security system on a door allows a user to type a code
into a keypad to enter the room. If an incorrect code is
input, an error message is shown and a short alarm
sound is played.
An algorithm is a set of
instructions for solving a
problem or accomplishing a task.
Example of an algorithm (Real Life)
Example of an algorithm (Real Life) - Driving a car
Walk to the
parking space Letgoooo!
Turn on the
engine
Example of an algorithm (Software) - Alarm clock
If both matches,
send signal to
sound system
Flowchart and pseudocode are an effective way to
communicate how the algorithm that makes up a
system or a sub-system work.
Flowchart Pseudocode
Flowchart and pseudocode are an effective way to
communicate how the algorithm that makes up a
system or a sub-system work.
Flowchart
Have a look at a
flowchart showing
how the checking for
the alarm time
subsystem works, can
you understand what
is it doing?
Components of a flow chart
Terminator process Input/output
Used at the Show the input of
Represent an
beginning and end data and output
instruction
of each flowchart of information
No matter how Protecting the
small the environment is
ecosystem on the same as
earth, everything protecting the
is interconnected ecosystem
Components of a flow chart
Decision
• Used to decide which action is to be taken
next
• There are always two outputs from a decision
flowchart symbol
Components of a flow chart
subroutine Flowline
• Represents a smaller • Use arrows to show the
procedure running within direction of flow
the large program.
• Abstraction in action
• Could be
another
flowchart
defined
elsewhere
Input/
output
Terminator
subroutine
process
Decision
A computer program allows a user to
input two numbers. It multiplies the
Analysis
numbers together and if the answer is
larger than 100 it outputs the message Input:
"Greater than 100". The program loops
until the user does not want to input
Output:
any more numbers. Process:
Draw a flowchart that represents an
algorithm for the computer program.
A computer program allows a user to
Analysis
input two numbers. It multiplies the
numbers together and if the answer is Input: Number 1 & 2
larger than 100 it outputs the message
"Greater than 100". The program loops
Output: Message >100
until the user does not want to input Process:
any more numbers.
- if N1 + N2 > 100,
Draw a flowchart that represents an
algorithm for the computer program. output message >100
- process continue until
user does not want to
input numbers
A computer program allows a user to
input two numbers. It multiplies the
numbers together and if the answer is
larger than 100 it outputs the message
"Greater than 100". The program loops
until the user does not want to input
any more numbers.
Terminator
Algorithm &
Pseudocode
fake, pretentious
What is Pseudocode?
Pseudocode
• Person reading the pseudocode
does not need to have
knowledge in a programming
language to understand the
algorithm
• Commonly used in Computer
Science research paper
Input Iterative
Assignment Conditional
and Statement Statement
statement
Output
Assignment statement
Variable Value
Value
[Link] values on the right can have one value or multiple value
combined with mathematical operators.
Assignment statement
x 5 x 5 *6
name "Adam" name "Hello" + " Adam"
The values on the right can have one value or multiple value
combined with mathematical operators.
Mathematical operators
Operator Action
+ Addition
- Subtraction
* Multiply
/ Divide
^ Raise to the power of
() Group
Assignment statement
Keyword: REFER
Answer
• Price ← Cost * 2
• Tax ← Price * 0.12
• Selling price ← Price + Tax
• Gender ← "M"
• Chosen ← FALSE
Assignment statement - ARRAY
Store value
1 2 3 4 5 6 7 8 9 10
Peter Jane
Previous examples:
Assigning an array to a variable
1 2 3 4 5 6 7 8 9 10
Peter Jane
Input and Output
Input Output
Used for data Used to display
entry; it is usually information on a
followed by a screen
variable where
the data input is
stored
INPUT cost
Price ← Cost * 2
Tax ← Price * 0.12
Selling price ← Price + Tax
OUTPUT selling price
Conditional
• An element of pseudocode which allows the algorithm to do
different things depending on the input/scenario
INPUT Age
IF Age < 18
THEN
OUTPUT "Child"
ELSE
OUTPUT "Adult"
ENDIF
IF ... THEN ... ELSE ... ENDIF
INPUT Height
INPUT Weight
IF Height > 170 AND Weight < 85
THEN
OUTPUT "YOU MEET THE REQUIREMENT"
ELSE
OUTPUT "YOU NEED TO BE TALLER OR LIGHTER".
ENDIF
CASE OF ... OTHERWISE ... ENDCASE
• For a CASE statement the value of the variable decides the path
to be taken. Several values are usually specified.
INPUT FoodToBuy
CASE OF FoodToBuy
Milo : OUTPUT "Here's your milo"
Biscuit : OUTPUT "Here's your biscuit"
OTHERWISE : OUTPUT "The canteen does not have this food"
ENDCASE
Specify which variable we are
CASE OF ... OTHERWISE ... ENDCASE
looking into when deciding
which path to take
INPUT FoodToBuy
CASE OF FoodToBuy
Milo : OUTPUT "Here's your milo"
Biscuit : OUTPUT "Here's your biscuit"
OTHERWISE : OUTPUT "The canteen does not have this food"
ENDCASE
Path that will be taken if the variable is
Choices
neither "Milo" nor "Biscuit"
INPUT Grade
CASE OF Grade
A : OUTPUT "Excellent"
B : OUTPUT "Not bad huh"
C : OUTPUT "Fair"
D : OUTPUT "Why you sleep in my class?"
OTHERWISE : OUTPUT "Invalid input"
ENDCASE
Iterative statement
• An element of pseudocode which allows the algorithm to
repeat certain actions.
FOR... WHILE...
REPEAT...
TO... DO...
UNTIL...
NEXT... ENDWHILE
A repetition, where
A repetition, where
the number of
the number of
A set number repeats is not
repeats is not known,
of repetitions known, that may
that is completed at
never be
least once
completed
FOR...
TO...
NEXT...
FOR Counter ← 1 TO 10
A set number
of repetitions OUTPUT Counter
NEXT
Beginning value
FOR... Ending value
TO...
NEXT...
FOR Counter ← 1 TO 10
A set number
of repetitions OUTPUT Counter
NEXT
Counter +1
What does the above pseudocode do?
What does the below pseudocode do?
Beginning value
FOR... Ending value
TO...
NEXT...
FOR Counter ← 1 TO 10
A set number
of repetitions OUTPUT "Enter Name of Student "
INPUT StudentName[Counter]
NEXT
Counter +1
ANSWER: Ask the user for 10 names iteratively,
and then place each name into the array.
1 2 3 4 5 6 7 8 9 10
REPEAT...
UNTIL... REPEAT
OUTPUT "Hello"
A repetition,
where the
INPUT Option
number of Until Option = -1
repeats is not
known, that is
completed at
least once
REPEAT...
UNTIL... REPEAT
OUTPUT "Hello"
A repetition,
where the INPUT Option
number of
repeats is not
Until Option = -1
known, that is
completed at
least once Condition to determine whether we
want to continue our program
What does the code below do?
Total ← 0
Mark ← 0
REPEAT... REPEAT
UNTIL... Total ← Total + Mark
OUTPUT "Enter value for mark, -1 to finish "
INPUT Mark
UNTIL Mark = -1
Answer: In each iteration, ask the user for a mark. The
mark given will be added to the total. The program stops
when the user enter the value -1.
Total ← 0
REPEAT... Mark ← 0
UNTIL... REPEAT
Total ← Total + Mark
A repetition,
OUTPUT "Enter value for mark, -1 to
where the finish"
number of
repeats is not
INPUT Mark
known, that is UNTIL Mark = -1
completed at
least once
WHILE...
Total ← 0
DO...
OUTPUT "Enter value for mark, -1 to finish "
ENDWHILE
INPUT Mark
WHILE Mark <> -1 DO
A repetition,
Total ← Total + Mark
where the number
of repeats is not OUTPUT "Enter value for mark, -1 to finish"
known, that may INPUT Mark
never be
ENDWHILE
completed
WHILE...
Total ← 0
DO...
OUTPUT "Enter value for mark, -1 to finish "
ENDWHILE
INPUT Mark
WHILE Mark <> -1 DO
Total ← Total + Mark
OUTPUT "Enter value for mark, -1 to finish"
Block that
INPUT Mark
will be
executed ENDWHILE
by the DO Condition to decide
keyword whether the DO
block will be run
Standard methods
of solutions
Totalling
• Totalling means keeping a total that values are added to.
For example, keeping a running total of the marks
awarded to each student in a class.
StudentMark
70 : 75 80 60 70 65 75 90 95 100
Totalling
StudentMark[1:10]
70 75 80 60 70 65 75 90 95 100
StudentMark[1:10]
70 75 80 60 7 65 75 25 95 100
Counting
70 75 80 60 7 65 75 25 95 100
PassCount ← 0
ClassSize ← 10
FOR Counter ← 1 TO ClassSize
IF StudentMark[Counter] > 50
THEN
PassCount ← PassCount + 1
NEXT Counter
Test your understanding
StudentName
Ali : Zak Bb Ali ZZ J
AliCount ← 0
ClassSize ← 6
FOR Counter ← 1 TO ClassSize
IF StudentName[Counter] = "Ali"
THEN
AliCount ← AliCount + 1
NEXT Counter
Maximum and minimum
• Finding the maximum and minimum of a given array. Eg.
Find the highest and lowest mark awarded to a class of
students.
StudentMark
70 : 75 80 60 7 65 75 25 95 100
Maximum and minimum
• Method 1: Set the MaximumMark to be 0. Set the
MinimumMark to be 100.
MaximumMark ← 0
MinimumMark ← 100
ClassSize ← 10
FOR Counter ← 1 TO ClassSize
IF StudentMark[Counter] > MaximumMark
THEN
MaximumMark ← StudentMark[Counter]
ENDIF
IF StudentMark[Counter] < MinimumMark
THEN
MinimumMark ← StudentMark[Counter]
ENDIF
NEXT Counter
Maximum and minimum
• Method 2: Set the MaximumMark and MinimumMark to be
StudentMark[1]
MaximumMark ← StudentMark[1]
MinimumMark ← StudentMark[1]
ClassSize ← 10
FOR Counter ← 1 TO ClassSize
IF StudentMark[Counter] > MaximumMark
THEN
MaximumMark ← StudentMark[Counter]
ENDIF
IF StudentMark[Counter] < MinimumMark
THEN
MinimumMark ← StudentMark[Counter]
ENDIF
NEXT Counter
Average
• Finding the average value of a given array. Eg. Find the
average mark awarded to a class of students.
StudentMark
70 : 75 80 60 7 65 75 25 95 100
Average
• Finding the average value of a given array. Eg. Find the
average mark awarded to a class of students.
Total ← 0
FOR Counter ← 1 TO ClassSize
Totalling
Total ← Total + StudentMark[Counter]
NEXT Counter
Average ← Total / ClassSize
Average
• Finding the average value of a given array. Eg. Find the
average mark awarded to a class of students.
Total ← 0
FOR Counter ← 1 TO ClassSize
Total ← Total + StudentMark[Counter]
NEXT Counter
Average ← Total / ClassSize
Linear search
• A type of search that is used to check if a value is stored in a
list, performed by going through the items in the list one at a
time. Eg. Searching for a name in a class list of students name,
where all the names stored are different.
StudentName:
ZK Lyn Tam YW Dan Joh Abd
Linear search
StudentName:
ZK Lyn Tam YW Dan Joh Abd
Found!
REPEAT
IF Name = StudentName[Counter]
THEN
Found ← TRUE
ELSE
Counter ← Counter + 1
ENDIF
UNTIL Found ← TRUE OR Counter > ClassSize
IF Found
THEN
OUTPUT Name, " found at position ", Counter, " in the list."
ELSE
OUTPUT Name, " not found."
ENDIF
Bubble sort
• Lists can be more useful if the items are sorted in a meaningful
order. For example, names could be sorted in alphabetical order,
or numbers could be sorted in ascending or descending order.
Sorting Names:
ZK Lyn Tam YW Dan Joh Abd
Sorting Numbers:
7 6 5 4 3 2 1
1 2 3 4 5 6 7
Bubble sort
REPEAT
Swap ← FALSE
FOR Index ← First TO Last - 1
IF Temperature[Index] > temperature[Index + 1]
THEN
Temp ← Temperature[Index]
Temperature[Index] ← Temperature[Index + 1]
Temperature[Index + 1] ← Temp
Swap ← TRUE
ENDIF
NEXT Index
Last ← Last - 1
UNTIL (NOT Swap) OR Last = 1
C7.6
VALIDATION AND
VERIFICATION
Saad Shah
IN ORDER FOR COMPUTER SYSTEMS TO ONLY ACCEPT DATA INPUTS THAT ARE
REASONABLE AND ACCURATE, EVERY ITEM OF DATA NEEDS TO BE EXAMINED
BEFORE IT IS ACCEPTED BY THE SYSTEM.
VALIDATION VERIFICATION
FOR DATA VERIFICATION
ENTRY, IS USED TO
VALIDATION CHECK THAT
ENSURES THAT THE DATA DOES
ONLY DATA NOT CHANGE
THAT IS AS IT IS BEING
REASONABLE ENTERED.
IS ACCEPTED.
VALIDATION
54 35 102
VALIDATION
Range
THE CODE WILL REPEATEDLY ASK
Check THE USER FOR MARK INPUT AS
LONG AS THE MARK IS NOT
WITHIN THE RANGE 0-100
ABCDEFGHIJKLMN
ABCD12345 ABCD OPQRSTUVWXYZ
VALIDATION
length
THE CODE WILL REPEATEDLY ASK
Check THE USER FOR NAME INPUT AS
LONG AS THE LENGTH OF THE
NAME IS NOT WITHIN 2 TO 30
CHARACTERS.
3 3.2 THREE
VALIDATION
TYPE
IT CHECKS WHETHER THE NUMBER
Check IS A WHOLE NUMBER. IF NOT,
USER WILL BE PROMPTED TO
INPUT AGAIN!
ABC@[Link] ""
VALIDATION
Presence
check
DEFINITION
A PRESENCE CHECK CHECKS TO ENSURE THAT SOME DATA HAS BEEN ENTERED
AND THE VALUE HAS NOT BEEN LEFT BLANK, FOR EXAMPLE, AN EMAIL ADDRESS
FOR AN ONLINE TRANSACTION MUST BE COMPLETED.
check DEFINITION
A FORMAT CHECK CHECKS THAT THE CHARACTERS ENTERED CONFORM TO A
PRE-DEFINED PATTERN.
TESTING
TESTING
• A program needs to be tested thorougly to ensure that it
is working as intended.
• Before a whole system is tested, each sub-system is
tested separately (eg. Pseudocode, flowchart).
• However, in order to test a solution thoroughly it may
need to be worked through several times with different
sets of test data.
DATA THAT CAN BE USED FOR TESTING
WE NEED TO -5 75 80 60 70 65 INCORRECT
TEST THAT OUR AVERAGE
PROGRAM WILL
SCORE
REJECT THIS
DATA
NORMAL DATA THAT WOULD BE EXPECTED
57.5
EXTREME EXTREME DATA ARE THE LARGEST AND SMALLEST
DATA VALUES THAT NORMAL DATA CAN TAKE
EXAMPLE 1 EXAMPLE 2
10 11 1 0
EXAMPLE 1 EXAMPLE 2
EXAMPLE 1 EXAMPLE 2
4 3 15 16
1 9 9 9
2 9 7 7
3 9 3 3
4 9 1 1 91
0 0 100
1 19 19 19
2 27 19 27
3 31 19 31
4 31 14 14 31 14
0 0 100
1 9 9 9
2 9 7 7
3 9 3 3
4 9 1 1 91
0 0 100
1 13 13 13
2 17 13 17
3 21 13 21
4 21 11 11 21 11
C7.9
of an algorithm
using a Trace Table
The algorithm on the left will ouput out the
maximum and minimum value, but does it work?
A B C X Output
Try it yourself!
Test Data: 400, 101, 200, 700
Max Min
A B C X Output
Try it yourself!
Test Data: 400, 101, 200, 700
Explanation
By declaring C to 100, we can only detect a minimum value that is
below 100. Eg. All test data are (400, 101, 200, 300), even though 101
is the minimum value among all the other values, it still cannot be
detected as it is more than 100.
The algorithm on the left will ouput out the
maximum and minimum value, but does it work?
A B C X Output
Try it yourself!
Test Data: -7, -5, -3,-6
Max Min
A B C X Output
Try it yourself!
Test Data: -7, -5, -3,-6
Explanation
By declaring B to 0, we can only detect a maximum value that is
above 0. Eg. All test data are (-5 , -3, -2 , -7), even though -2 is the
maximum value among all the other values, it still cannot be detected
as it is not more than 0.
We can fix it - quick fix
IF NumberOfTickets < 10
THEN
Discount ← 0
Answer ELSE
IF NumberOfTickets < 20
THEN
Discount ← 0.1
ELSE
Discount ← 0.2
ENDIF
ENDIF
Cost ← NumberOfTickets * 20 * (1 – Discount)
OUTPUT "Your tickets cost ", Cost
REPEAT
OUTPUT "How many tickets would you like to buy? "
INPUT NumberOfTickets
UNTIL NumberOfTickets > 0 OR NumberOfTickets < 26
IF NumberOfTickets < 10
create some test THEN
data to check the Discount ← 0
correctness of an ELSE
IF NumberOfTickets < 20
algorithm THEN
Discount ← 0.1
ELSE
Discount ← 0.2
ENDIF
ENDIF
Cost ← NumberOfTickets * 20 * (1 – Discount)
OUTPUT "Your tickets cost ", Cost
eg. REPEAT
OUTPUT "How many tickets would you like to buy? "
INPUT NumberOfTickets
Test data = 12 UNTIL NumberOfTickets > 0 OR NumberOfTickets < 26
Discount = 10%
IF NumberOfTickets < 10
Calculation=
THEN
Discount ← 0
(12 x 20) * 0.9 = ELSE
IF NumberOfTickets < 20
$216
THEN
Discount ← 0.1
Now, go through ELSE
Discount ← 0.2
the algorithm to
ENDIF
check if it works ENDIF
as expected with Cost ← NumberOfTickets * 20 * (1 – Discount)
OUTPUT "Your tickets cost ", Cost
the test data.