Page 1 of 1

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

#1 PixelCard  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 47
  • View blog
  • Posts: 139
  • Joined: 20-June 08

Posted 29 July 2008 - 10:01 AM

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:

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.

Is This A Good Question/Topic? 1
  • +

Replies To: Using pseudo-code to design application logic

#2 williamgeorgegardner  Icon User is offline

  • CEO of GeekTelligence
  • member icon

Reputation: 19
  • View blog
  • Posts: 584
  • Joined: 27-December 09

Posted 14 March 2010 - 01:25 PM

This is a great tutorial!!!!
Was This Post Helpful? 0
  • +
  • -

#3 f1alan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 10-August 10

Posted 10 August 2010 - 12:55 AM

View PostPixelCard, on 29 July 2008 - 09:01 AM, said:

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.


Hi,

This is a very good tutorial for those unfamiliar with pseudocode. I am also of the opinion that designing methods properly using pseudocode is extremely valuable. By jumping straight into the code, it is very easy to get distracted by implementation details. Having a solid design will result in better quality code.

We've seen particular benefits of Code Rocket which can produce code and flowchart from your pseudocode.

Well done again on a good post.

Alan

This post has been edited by f1alan: 10 August 2010 - 01:03 AM

Was This Post Helpful? 0
  • +
  • -

#4 bennitto  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 64
  • Joined: 28-November 09

Posted 14 August 2010 - 05:55 PM

I have known of pseudo code and I often use it but I tend to use a more general form as I am still learning to program and working on programs reaching barely 500 lines.

I tend to start with the computer straight away(which sometimes is not a good idea) but using pseudo code afterwards helps me solve problems easier
Was This Post Helpful? 0
  • +
  • -

#5 pablo9891  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 41
  • Joined: 19-December 09

Posted 10 June 2012 - 02:15 AM

Great Tutorial!!. I'd like to add something and that is that the abstract model of what you are going to build in a computer (the algorithm)is a really important thing in computing in general, even if you are doing a really small program you always have to keep that model in mind. Pseudocode is a way of treating that abstraction in a direct way and it allows you to see alternatives and mistakes in what you are going to code then.
Was This Post Helpful? 0
  • +
  • -

#6 ladkins1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 15-June 14

Posted 15 June 2014 - 11:23 AM

I'm new to coding and in the midst of a career change. As I have been studying, I want to get all that I can from my lessons, however, I feel that it can be intimidating. However, your breakdown of pseudo-code is breath of fresh air. Thank you for your layman terms and making it plain and simple. I look forward to learning from you and this site. And yes, I'm doing my OWN homework. :-)
Was This Post Helpful? 0
  • +
  • -

#7 k.dombek  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-August 14

Posted 06 August 2014 - 08:33 PM

View Postbennitto, on 14 August 2010 - 05:55 PM, said:

I have known of pseudo code and I often use it but I tend to use a more general form as I am still learning to program and working on programs reaching barely 500 lines.

I tend to start with the computer straight away(which sometimes is not a good idea) but using pseudo code afterwards helps me solve problems easier

Serious suggestion - do the pseudo code first - then you won't waste the time spent coding the wrong thing.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1