 # Desk Checking

It is a technique for verifying the logic of an algorithm. It does not involve use of a computer, rather a person is responsible to carry out the desk check. The desk checker observes and analyses the logic behind the algorithm. This technique is quite relevant before beginning with coding, as the algorithm lays the foundation upon which the code will be built, so desk checking ensures implementation of the right type of code.

A desk check is performed by segregating the data into different columns, with each column having a name that represents some value. Let us have a look at the following table :

Desk Check
Line Number x Conditions Input/Output
1.
2.
3. 1
4. "1<3 is true"
5. Hello
6. 1+1=2
4. 2<2 id true
5. Hello
6. 2+1=3
4. 3<3 is false
8.

• Line Number :This is to check the number of lines to be executed.
• One column per variable :The variables are placed in an alphabetical order. As the algorithm proceeds new values are added to the consecutive columns. The final column is ideally for representing the output/result of the calculations.
• Condition :A condition column is used to show the evaluation of some condition. The result of the condition will will either be true or false.
• Input/output column :Input/output column shows the inputs by a user and the outputs generated by the system.

The process of desk checking typically involves the following steps :

• Understand the given problem :It is of course an important thing to understand the problem from every possible dimension, in order to devise the most appropriate solution for it.
• Specify a high level solution :Defining a solution means, after analysing the problem, one is required to determine the outputs, the process need to be followed in the process of attaining the right results, inputs required.
• Develop the outline :After gathering such data, we should be able to sketch an outline/design of the solution.
• Develop the algorithm :The simple thing here is to begin with writing the algorithm for the problem under consideration.
• Test the algorithm : Perform desk checking, validate that the logic that the algorithm depicts is worthy/suitable enough to generate the required output.

Lets see an example to understand each step of desk checking.

• Problem :

Calculate the discounted price of an item purchased by a consumer.

• Solution :

The problem requires calculation of price of an item. So the variables used will be - input_price, discount_percent, discount, discount_price.

• Prepare Outline
• Input Processing Output
item_price Calculating
the discount rate
Actual
discount value
• Algorithm :
1. calculate_discountPrice()
2. declare input_price, discount_percent
3. discount = input_price * discount_percent/100
4. discount_price = input_price - discount
5. Display discount_price
6. stop
• Test Data

This step is to check the output of the actual code.

Inputs : input_price, discount_percent output : discount_price

• Catch a bug even before it occurs. An experienced programmer also tends to make mistakes, so desk checking is a way to take precaution in that regard.
• It is an inexpensive and quick technique.
• As the programmer writes the code/algorithm on his own, he can check if there is any issue or not, and fix the same before the project moves on to the later stages.

• Although the programmer is in a position to find out the errors in their own code, it may sometimes be otherwise. He may not be able to track the issue/bug in the code, which may result in erroneous outcomes.

## Conclusion :

Desk checking enables developers to proceed in a very systematic manner, in terms of coding. This technique eliminates the chances of erroneous code as proper review is done to analyse the problem and therefore offer the best solution for a given problem.

Get New Content Update
Popular Posts Dec 07, 2020 Dec 07, 2020 Dec 07, 2020