[go: up one dir, main page]

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

Paper 2 Part 3 StepWise Refinement and Testing

Uploaded by

millercuilb
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 views7 pages

Paper 2 Part 3 StepWise Refinement and Testing

Uploaded by

millercuilb
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/ 7

Step Wise Refinement refers to the process of splitting a problem into smaller sub problems.

These sub problems are then divided into even


smaller sub problems until each problem represents just one element of the final program.
Sub problems can be referred to as “Sub Routines”. The Resulting diagram is known as Structure Chart.
Subroutine:-
A subroutine is a self-contained section of the program code that performs a specific task as part of the main program. Sub routines can be
either procedures (Null Function) or functions (Fruitful Function).

Consider the alarm app computer system for a


smart phone. This could be
divided into three sub-systems, setting the
alarm, checking for the alarm time, sounding
the alarm.
These sub-systems could then be further sub-
divided the structure diagram makes the
process clearer.

Library Routines:-
A LIBRARY ROUTINE is a set of programming instructions for a given task that is already available for use. It is pre-tested and usually
performs a task that is frequently required.
Test Data:-
To determine whether a solution is working as it should it needs to be tested. Both whole system and subsystems as well.
In order to be tested fully it needs to be worked through several times with different test data i.e SET OF TEST DATA. Test data needs to
be of the following types:-
• Normal Test Data:-
• Will result on normal execution of the program to produce results. The produced result should then be compared with the
“expected” results. If both achieved results and expected results are same then the codes is working as it should.
• For example the normal test data for percentages of exam results achieved can be
• 50,60,80,70,100
• the expected value when finding average of these percentages should be 72.
• Erroneous Or Abnormal Test Data:-
• Should be rejected by the program and appropriate expected steps should be executed (for example printing an error message).
• for percentages of marks the following data should result on errors:-
• -11 and eleven.
• Extreme Data:-
• The upper and lower limits of acceptable value (should be accepted)
• 0 and 100 are extreme values for exam percentages scenario.
• Boundary Data:-
• The data that lies beyond the acceptable range. (should be rejected)
• 101 or -1
Validation • Range Check
Is data • Only numbers in specified are accepted
Sensible? • Percentages should be between 0 and 100
• Length Check
• The number of characters should be a certain number.
• Passwords need to be at least 8 characters long.
• Type Check
• Data has to be a certain type.
• Number of brothers and sisters need to be whole numbers only. (integers values)
• Character Check
• String of characters should not include invalid characters
• A name should not have # or %
• Format Check
• The character should be of a pre defined pattern
• User ID should have 2 letters and then 4 numbers. AB1234
• Presence Check
• A field or data cannot be left empty.
• Email address must be entered.
• Check Digits
• Final digit in code is calculated with existing data. If the recalculation results in a different value then an error is identified.
• ISBN or Vehicle Identification numbers

Verification • Double Entry


Is data • Data is entered twice both entries are compared for differences (errors)
accurate • Screen Visual Check
according to • Manual check or entered data by displaying the entered information before continuing.
previously • Parity Check and Checksum
stored value? • Discussed in section 1.2
Dry Running and Trace Tables:-
We can check that an algorithm works as intended (or even for finding out what it does) by “dry-running” the algorithm and updating a trace
table with the test data. The trace table contains a column for each variable. The values that change in the table are then noted accordingly.
Furthermore, the following rules have to be kept in mind when working with trace tables:-
- Entries are only made in a cell when an assignment occurs.
- Values remain in variables until overwritten.
- If the cell is blank this indicates that the previous value remains.
- A new new ROW should be allocated for each new iteration (step in loop) in the Trace Table.
A B C X OUTPUT
0 9 9 9
1 7 7
2 3 3
3 12 12
4 6
5 4
6 15 15
7 2 2
8 8
9 15 2
SYNTAX Error is when you are have made a mistake in writing the program according to Programming Language Rules. The CODE
WILL NOT RUN.
Corrective Maintenance:-
Code Changes when the program is not working correctly due to a “logical” error or a “run time” error.
- usually such type of errors become evident early on during the development process.
- however under certain circumstances these errors may not be revealed immediately.
- for example the “bug” lies in a part of code that hasn’t been executed that often.
- or the program or part of program may have not been subjected “extreme” values before.
Adaptive Maintenance:-
Code Changes when program to enhance functionality or in response to changing specifications.
Finding Logical Errors:-
Finding Logical Errors:-
The best approach is always dry running the algorithm to find logical errors. Furthermore
you need to consider the following:-
• Line1:
• in such questions where you have to find the smallest or largest values you should
initialise the largest with 0 and smallest with an abnormally large number (as
nothing is smaller that 0, usually) that lies on the upper extreme of a valid inputs.
so in this case Large should be assigned with 0.
• Line 3:
• while loop (post condition) relies on the condition to be TRUE for it to resume.
Here we can see that the condition is already FALSE(as counter is already <30)
and hence the loop will never run. We will have to change the statement to
counter<30
• Line6:
• if we are comparing the largest number we need to see if the newly entered
number is larger that the existing largest number therefore the statement should
be “Num>Large”

• Line 7:-
• Our rogue value is the counter becoming more than 30. But here we can see that
the counter is not incrementing rather decrementing in each iteration (step). The
statement should be counter=counter+1

You might also like