Introduction
Before developing an application it needs to be somehow designed - on a piece of paper, using UML or just by creating a prototype. Another way to design the application logic is using pseudo-code.
What is pseudo-code and how to use it?
Pseudo-code is a non-formal language, a way to create a logical structure, describing the actions, which will be executed by the application. Using pseudo-code, the developer describes the application logic using his native language, without applying the structural rules of a specific programming language. The big plus of the pseudo-code is that the application logic can be easily understood by any developer in the development team (in this case, it doesn’t depend, which programming language knows each team member). Also, when the application algorithm is described in pseudo-code, it is very easy to transform the pseudo-code into real code (using any programming language). For a better understanding of what is pseudo-code, let’s take a look at an example. Suppose that you have to develop an application, that gets the number of students in a high school and then it gets each student’s final grade (100, 90, 80, 60 and 50) and processes the average grade for the whole school. Instead of creating the program at a computer, let’s describe the application logic using pseudo-code. First, I will describe the general purpose of the application:
Process the average grade for the whole school
Now, I need to specify the fundamental actions that are needed to process the final result:
Request the number of students; Get the grade for each student; Process the average grade for the whole school;
This is a generalized description, but it describes the basic application logic. Now, I have to specify some more details (how the above actions are performed):
Application start; Declare an integer variable numberOfStudents; Declare an integer variable counter; Declare an integer variable sum; Declare a decimal variable average; Set the numberOfStudents value to 0; Set the counter value to 0; Set the sum value to 0; Request the number of students (numberOfStudents); If the entered number of students is 0 then Exit the application Else While the counter is less or equal to the number of students Get the student grade Add the student grade to the sum variable Increment the counter by 1. Get the next student information When the student information is entered, set the average variable to the result of the division (sum divided by the number of students). Show the result. Application end.
As you see, I used a human language to describe the application logic. Also, to better see the code fragments, I used a specific indentation style, so I can easily see which part of the algorithm is executing a specific action.
Some developers may think that using pseudo-code to design the application instead of creating and testing the application on the computer is a waste of time. This is true for small modules, that were created many times and which require just some small modifications to accomplish a specific task, but when it comes to large projects, it’s pretty easy to be lost in the hundreds or even thousands of code lines. In this case, the pseudo-code clearly describes the application algorithms, so these can be easily implemented and it gives the developer an opportunity to think on the algorithm before implementing it.





MultiQuote





|