Desk Checking.

Slides:



Advertisements
Similar presentations
Desk Checking. Desk checking is a manual (non computerised) technique for checking the logic of an algorithm. The person performing the desk check effectively.
Advertisements

How SAS implements structured programming constructs
CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
Programming Logic and Design Eighth Edition
CHAPTER 5: Repetition Control Structure. Objectives  To develop algorithms that use DOWHILE and REPEAT.. UNTIL structures  Introduce a pseudocode for.
CS0004: Introduction to Programming Repetition – Do Loops.
08 Deterministic iteration1May Deterministic iteration CE : Fundamental Programming Techniques.
Repeating Actions While and For Loops
Program Design and Development
16/27/ :53 PM6/27/ :53 PM6/27/ :53 PMLogic Control Structures Arithmetic Expressions Used to do arithmetic. Operations consist of +,
Computer Programming 1 Repetition. Computer Programming 2 Objectives Repetition structures Study while and do loops Examine for loops A practical example.
Selection Control Structures. Simple Program Design, Fourth Edition Chapter 4 2 Objectives In this chapter you will be able to: Elaborate on the uses.
CPS120 Introduction to Computer Programming The Programming Process.
ANALYSIS AND ALGORITHM DESIGN - IV. Repeat statements/looping/counting/iterations It is often necessary to repeat certain parts of a program a number.
Data Structures and Algorithms Introduction to Algorithms M. B. Fayek CUFE 2006.
Control Structures (A) Topics to cover here: Introduction to Control Structures in the algorithmic language Sequencing.
Visual Basic Programming
Lecture 4: Calculating by Iterating. The while Repetition Statement Repetition structure Programmer specifies an action to be repeated while some condition.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 4 Looping.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 ‏ Control Structures.
1 CSCI N201 Programming Concepts and Database 9 – Loops Lingma Acheson Department of Computer and Information Science, IUPUI.
Algorithm Design.
Advanced Program Design. Review  Step 1: Problem analysis and specification –Specification description of the problem’s inputs and output –Analysis generalize.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 8 Arrays.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Higher Computing Software Development -So Far- 5/10/10.
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
Fourth Quarter.  Involves loops or cycles ◦ Loops: means that a process may be repeated as long as certain condition remains true or remains false. ◦
Why Repetition? Read 8 real numbers and compute their average REAL X1, X2, X3, X4, X5, X6, X7, X8 REAL SUM, AVG READ *, X1, X2, X3, X4, X5, X6, X7, X8.
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
Selection Using IF THEN ELSE CASE Introducing Loops.
Zhen Jiang Dept. of Computer Science West Chester University West Chester, PA CSC530 Data Structures - LOOP 7/9/20161.
CMSC 104, Version 8/061L05Algorithms2.ppt Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode Control Structures Reading Section 3.1.
REPETITION CONTROL STRUCTURE
2008/09/22: Lecture 6 CMSC 104, Section 0101 John Y. Park
GC211Data Structure Lecture2 Sara Alhajjam.
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
CHAPTER 5A Loop Structure
CS1371 Introduction to Computing for Engineers
Introduction To Flowcharting
Chapter 5: Repetition Structures
Algorithm and Ambiguity
Computer Science 101 While Statement.
2008/09/24: Lecture 6b CMSC 104, Section 0101 John Y. Park
Chapter 6 – Repetition 6.1 Do Loops 6.2 For...Next Loops
Control Structure Senior Lecturer
TOPIC 4: REPETITION CONTROL STRUCTURE
Program Design Introduction to Computer Programming By:
Pseudocode algorithms using sequence, selection and repetition
Chapter 6: Repetition Structures
Chapter 5: Repetition Structures
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Algorithm Discovery and Design
Iteration: Beyond the Basic PERFORM
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Faculty of Computer Science & Information System
Algorithm and Ambiguity
Python programming exercise
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
CHAPTER 4 Iterative Structure.
Flowcharts and Pseudo Code
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Incremental Programming
REPETITION Why Repetition?
Chapter 5 Desk Checking/Dry Running.
Module 4 Loops and Repetition 9/19/2019 CSE 1321 Module 4.
Presentation transcript:

Desk Checking

Desk Checking Desk checking is a manual (non computerised) 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: 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) 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. 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. 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 .

Desk Checks vs Test Plans A Desk Check concentrates on the value of variables and the logic i.e. what is the value of variable x after statement n; what is the next statement to be executed? A Test Plan focuses on the values of inputs and outputs required to test a program without concern for the internal workings i.e. are the results (outputs) correct for the inputs?.

Sequence Desk Check 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

Sequence Desk Check Test Data Inputs: price = $200, discountPercent = 10%. Correct results: discount = $20, discountPrice = $180. Line Number discount Discount Percent 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

Selection Desk Check 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

Selection 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

Selection Desk Check cont. 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

Iteration Desk Check 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 the counter variable is incremented by 1, then program execution loops from the ENDFOR line, back to the FOR line. 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

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 <= 3 ? is T 4 1 * 1 = 1 5 x = 1, xSquared = 1 6 1 + 1 = 2 2 <= 3 ? is T 2 * 2 = 4 x = 2, xSquared = 4 2 + 1 = 3 3 <= 3 ? is T 3 * 3 = 9 x = 3, xSquared = 9 3 + 1 = 4 4 <= 3? is F 7 ----------- 8

Example from Case Study 1. Dim CashPaid, Change, GrandTotal As Currency 2. GrandTotal = txtnettotal.Text 3. CashPaid = txtcashtendered.Text 4. If GrandTotal > CashPaid Then 5. txtcashtendered.Text = "" 6. Else 7. Change = CashPaid - GrandTotal 8. End If

GrandTotal = 120 CashPaid = 200 Change should = 80 Line Number Conditions Input/Output 2  120   3 200 4 120 > 200 ? is F 7 Change = 200 - 120  Change = 80 8

Try this one… Dim Count As Integer Adodc1.Recordset.MoveFirst Do While Not Adodc1.Recordset.EOF Count = Count + 1 Adodc1.Recordset.MoveNext Loop txtNo_Records.Text = Count End Sub *5 records in database