Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,456 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,912 people online right now. Registration is fast and FREE... Join Now!




Using pseudo-code to design application logic

 
Reply to this topicStart new topic

> Using pseudo-code to design application logic, What is pseudo-code and how to use it.

PixelCard
Group Icon



post 29 Jul, 2008 - 09:01 AM
Post #1


In this tutorial I will describe the methods of designing the application logic using the pseudo-code.

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:

CODE
Process the average grade for the whole school


Now, I need to specify the fundamental actions that are needed to process the final result:
CODE

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):

CODE
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.

- Denis Delimarschi (PixelCard)
Go to the top of the page
+Quote Post


Register to Make This Ad Go Away!


Fast ReplyReply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 12/2/08 03:34PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month