1. UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
SOFTWARE ENGINEERING DEPARTMENT
Software verification and Validation 5th Term-SE UET Taxila
SOFTWARE VERIFICATION AND VALIDATION
LAB 06
PERFORMING A FORMAL REVIEW WITH DESK CHECKING
Desk Checking
Desk Checking is one of the older practices of human error-detection process. A desk check
can be viewed as a one-person inspection or walkthrough: A person reads a program, checks
it with respect to an error list, and/or walks test data through it.
Desk checking involves first running a spellchecker, grammar checker, syntax checker, or
whatever tools are available to clean up the cosmetic appearance of the document. Then, the
author slowly reviews the document trying to look for inconsistencies, incompleteness, and
missing information. Problems detected in the contents should be corrected directly by the
author with the possible advice of the project manager and other experts on the project.
Once all corrections are made, the cosmetic testing is rerun to catch and correct all spelling,
grammar, and punctuation errors introduced by the content corrections.
Desk checking is a manual (non computerized) technique for checking the logic of an
algorithm. The person performing the desk check effectively acts as the computer, using pen
and paper to record results. The desk checker carefully follows the algorithm being careful to
rigidly adhere to the logic specified. The desk check can expose problems with the algorithm.
Desk checks are useful to check an algorithm (before coding) thereby confirming that the
algorithm works as expected and saves time possibly writing a program that doesn't do what
was intended. Another benefit of a desk check is that it confirms to the programmer/designer
that the algorithm performs as intended.
A desk check is normally done as a table with columns for:
1. Pseudo code line number column (Pseudo code doesn't normally have lines
numbers, but these are necessary in a desk check to specify the line(s) being
executed)
2. One column per variable used. The columns should be in alphabetical order on
variable name with the variable name at the top of the column. As the algorithm is
executed, the new values of the variables are put in the appropriate column. Show
working for calculations. If variable names consist of a number of words it is
permissible to put a space between each word in the name so that the name fits
better in the column by wrapping to the next line. e.g. the variable column heading
discount Price could be used rather than the actual variable name discountPrice.
3. A condition column. The result of the condition will be true (T) or false (F). As the
algorithm is executed, conditions are evaluated and the details are recorded in the
column. Show working when evaluating the conditions. This is used whenever a
condition is evaluated - IF WHILE or FOR statements all have explicit or implicit
conditions.
2. UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
SOFTWARE ENGINEERING DEPARTMENT
Software verification and Validation 5th Term-SE UET Taxila
4. An Input/Output column is used to show what is input by the user and displayed by
the program. Show inputs with: the variable name, a "?" and the value input e.g.
price ? 200. Show outputs with the variable name, an =, and the value displayed (or
just the value displayed) e.g. discountPrice= 180.
Normally portrait page layout would be used for the desk check, however if the table is too
wide, landscape layout may be used.
Example 1
Problem Description: Calculate the discounted price of an item purchased. (Note: a problem
description is not normally specified in a desk check, it is only included to assist in
understanding the problem.)The following example shows desk checking involving sequence,
executing instructions one after the other.Sequence involves executing all instructions once,
from top to bottom, one after the other.
Algorithm (with line numbers added for the Desk Check)
1 calcDiscountPrice()
2 Input price, discountPercent
3 discount = price * discountPercent / 100
4 discountPrice = price - discount
5 Display discountPrice
6 STOP
Desk Check
Test Data
Inputs: price = $200, discountPercent = 10%.
Correct results: discount = $20, discountPrice = $180.
Line
Number
Discount
discount
Percent
discount Price price Input/Output
1
2 10 200
price ? 200;
discountPercent ? 10
3
200 * 10 / 100 =
20
4 200 - 20 = 180
5 discountPrice = 180
6
3. UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
SOFTWARE ENGINEERING DEPARTMENT
Software verification and Validation 5th Term-SE UET Taxila
Example 2
Problem Description: Calculate the discounted price of an item purchased.
Customers receive a discount of 15% on an item if the purchase price of the item is
over $100.
The following example shows desk checking involving selection using an IF.
For an IF without an ELSE, if the condition evaluates to True then execution continues to the
next line and the lines between the IF and ENDIF are executed (inclusive), otherwise (the
condition is False) execution jumps from the IF to the ENDIF.
Algorithm (with line numbers added for the Desk Check)
1 calcPrice()
2 Input price
3 IF price > 100 THEN
4 discount = price * 15 / 100
5 price = price - discount
6 ENDIF
7 Display price
8 STOP
Desk Check
Inputs: price = $200
Correct results: price = $170.
Line Number Discount Price Conditions Input/Output
1
2 200 price ? 200
3 200 > 100 ? is T
4 200 * 15 / 100 = 30
5 200 - 30 = 170
6
7 price = 170
8
4. UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
SOFTWARE ENGINEERING DEPARTMENT
Software verification and Validation 5th Term-SE UET Taxila
Inputs: price = $50
Correct results: price = $50.
Line Number discount price Conditions Input/Output
1
2 50 price ? 50
3 50 > 100 ? is F
6
7 price = 50
8
Example 3
Problem Description: Calculate the cost of electricity based on the electricity used.The
following example shows desk checking involving selection using a linear nested IF-ELSEs.
Algorithm (with line numbers added for the Desk Check)
1 calcElectrictyCost()
2 Input electricityUsed
3 IF electricityUsed < 1000 THEN
4 cost = 100
5 usageLevel = "Low"
6 ELSE
7 IF electricityUsed < 5000 THEN
8 cost = 100 + (electricityUsed - 1000) * 0.1
9 usageLevel = "Moderate"
10 ELSE
11 cost = 500 + (electricityUsed - 5000) * 0.08
12 usageLevel = "High"
13 ENDIF
14 ENDIF
15 Display cost, usageLevel
16 STOP
5. UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
SOFTWARE ENGINEERING DEPARTMENT
Software verification and Validation 5th Term-SE UET Taxila
Desk Check
Inputs: electricityUsed = 500,
Correct results: cost = 100, usageLevel = "Low".
Line
Number
cost
electricity
Used
usage
Level
Conditions Input/ Output
1
2 500 electricityUsed ? 500
3 500 < 1000 ? is T
4 100
5 Low
14
15
cost = 100, usageLevel =
"Low"
16
Inputs: electricityUsed = 3000,
Correct results: cost = 300, usageLevel = "Moderate".
Line
Number
Cost
electricity
Used
usage
Level
Conditions Input/ Output
1
2 3000 electricityUsed ? 3000
3
3000 < 1000
? is F
6
7
3000 < 5000
? is T
8
100 + (3000-
1000) * 0.1 =
300
9 Moderate
13
14
15
cost = 300, usageLevel
= "Moderate"
16
6. UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
SOFTWARE ENGINEERING DEPARTMENT
Software verification and Validation 5th Term-SE UET Taxila
Inputs: electricityUsed = 15000,
Correct results: cost = 1300, usageLevel = "High".
Line
Number
Cost
electricity
Used
usage
Level
Conditions Input/ Output
1
2 15000
electricityUsed ?
15000
3
15000 < 1000
? is F
6
7
15000 < 5000
? is F
10
11
500 + (15000-
5000) * 0.08 =
1300
12 High
13
14
15
cost = 1300,
usageLevel = "High"
16
Example 4
Problem Description: Display a table of values of x and x squared. X is to start at 1 and
increase by 1 up to 3.
The following example shows desk checking involving iteration (repetition) using a FOR loop.
The counter variable is initialized once at the top of the loop, the first time through the loop.
The implied condition is evaluated at the top of the loop, with execution going to the next
line if the condition is True and going to the line after the ENDFOR if the condition is False. In
this case the implied condition is x <= 3 ?. On the ENDFOR line t he counter variable is
incremented by 1, then program execution loops from the ENDFOR line, back to the FOR
line.
7. UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
SOFTWARE ENGINEERING DEPARTMENT
Software verification and Validation 5th Term-SE UET Taxila
Algorithm (with line numbers added for the Desk Check)
1 calcSquares()
2 Display "X", "X Squared"
3 FOR x = 1 TO 3 DO
4 xSquared = x * x
5 Display x, xSquared
6 ENDFOR
7 Display "-----------"
8 STOP
Desk Check
Test Data
Input: None
Correct results: x = 1, xSquared = 1; x = 2, xSquared = 4; x = 3, xSquared = 9.
Line Number X xSquared Conditions Input/ Output
1
2 X, X Squared
3 1 1 <= 3 ? is T
4 1 * 1 = 1
5 x = 1, xSquared = 1
6 1 + 1 = 2
3 2 <= 3 ? is T
4 2 * 2 = 4
5 x = 2, xSquared = 4
6 2 + 1 = 3
3 3 <= 3 ? is T
4 3 * 3 = 9
5 x = 3, xSquared = 9
6 3 + 1 = 4
3 4 <= 3? is F
7 -----------
8
8. UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
SOFTWARE ENGINEERING DEPARTMENT
Software verification and Validation 5th Term-SE UET Taxila
Lab tasks
****************************************************************
Lab Task 1
Problem Description: Display whether a student passed or failed a subject depending on their
mark.
Algorithm (with line numbers added for the Desk Check)
1 displayGrade()
2 Input mark
3 IF mark >= 50 THEN
4 grade = "Pass"
5 Display "Well done"
6 ELSE
7 grade = "Not pass"
8 ENDIF
9 Display grade
10 STOP
Perform Desk Check for the following sets of conditions
a. Inputs: mark = 75
Correct results: grade = "Pass", "Well done"
b. Inputs: mark = 40
Correct results: grade = "Not pass"
****************************************************************
Lab Task 2
Problem Description: Calculate the cost of water based on the water used and whether the
customer is a Domestic or Commercial user.
The following task shows desk checking involving selection using a non-linear nested IF-
ELSEs.ss
9. UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
SOFTWARE ENGINEERING DEPARTMENT
Software verification and Validation 5th Term-SE UET Taxila
Algorithm (with line numbers added for the Desk Check)
1 calcWaterCost()
2 Input waterUsed
3 IF waterUsed < 100 THEN
4 cost = 50
5 ELSE
6 Input customerType
7 IF customerType = "D" THEN
8 cost = waterUsed * 0.5
9 ELSE
10 cost = waterUsed * 0.6
11 Display "Commercial rate"
12 ENDIF
13 Display "High usage"
14 ENDIF
15 Display cost
16 STOP
Perform Desk Check for the following sets of conditions
a. Inputs: waterUsed = 70, customerType (not required)
Correct results: cost = 50
b. Inputs: waterUsed = 200, customerType = D
Correct results: cost = 100
c. Inputs: waterUsed = 200, customerType = C
Correct results: cost = 120
****************************************************************
Lab Task 3
Problem Description: Total a series of number input by the user. Allow the user to continue
inputting numbers until a negative number is input, then display the total of the numbers
input.
The following task shows desk checking involving iteration (repetition) using a WHILE loop.
The condition is evaluated at the top of the loop, with execution going to the next line if the
condition is True and going to the line after the ENDWHILE if the condition is False. Program
execution loops from the ENDWHILE line, back to the WHILE line.
10. UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
SOFTWARE ENGINEERING DEPARTMENT
Software verification and Validation 5th Term-SE UET Taxila
Algorithm (with line numbers added for the Desk Check)
1 totalNumbers()
2 total = 0
3 Input number
4 WHILE number >= 0 DO
5 total = total + number
6 Input number
7 ENDWHILE
8 Display total
9 STOP
Perform Desk Check for the following sets of conditions
Inputs: numbers = 10, 6, -1.
Correct results: total = 16
****************************************************************