Uses of Pseudo Code in Development

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

While working on my next article on interviewing programmers I made several mentions to the use of Pseudo code. I started detailing out the uses of Pseudo code and ended up creating a separate post dedicated to the subject. Hopefully this guide will be useful in relation to programmer interviewing but also for general reference for when to use Pseudo code in normal development.

For any complicated development task whether it be a single method or a whole project. It is important that every possible effort is taken to reduce complexity. Extra complexity without need can mean more mistakes are made so breaking a single tasks into two simpler tasks generally results in less complex code and less mistakes.

Writing pseudo code and program code separately simplifies the overall task by splitting it into two simpler tasks. While writing the algorithm the developer can focus on solving the problem, not how it is written in a a particular language. Once the pseudo code is written and has been checked; writing the real code becomes much simpler, the programmer is only concerned with converting the pseudo code into the appropriate program code.

Advantages of Pseudo Code

You don’t have to understand a particular programming language to understand Pseudo Code. It is written in semi-structured, somewhat English like manner. Pseudo code is written so that code based on it should be able to be written in any language (language independent). Using the algorithm the program could be written in C++, C, PHP, Ruby, Java or Visual Basic. Pseudo code can also assist in the natural breaking down of a programming problem into a smaller one that is easier to understand.

The Disadvantages of Pseudo Code

The disadvantages of pseudo code may start with its lack of standards. One person’s logic instructions may not seem as logical to the next. Given the unstructured nature of pseudo code, it is few rules and is hard to standardize. One programmer might not see the logic written by someone else.

Another disadvantage over other modeling tools like flowcharts may be pseudo codes inability to show logic flows or the bigger picture. Whereas flowcharts provide an overview of logic and can be understood at a higher level, pseudo code is far more detail oriented and requires more concentration and practice to see the bigger picture.

How to write Pseudo Code

First you may want to make a list of the main tasks that must be accomplished. Then, focus on each of those tasks. As I stated above you should try to break each main task down into very small tasks that can each be explained with a short phrase. In my experience it is a bad idea to go too close to the correlation of one-to-one between pseudo code and real code. The reason being that your pseudo code is there to help plan the structure but not to help resolve the details that fall out of real world programming.

The use of variables within pseudo code should be restricted if possible but when it is necessary you should show the initialization of the variables. Overall, remember that the purpose of pseudocode is to help the programmer efficiently write code. Therefore, you must attempt to add enough detail and analysis to the pseudo code. It can be that the pseudo code is being written by one programmer and the real code by another. In these circumstances it is best to follow a slightly more strict definition of pseudo code (I have supplied links to a few resources at the bottom).

There Are 13 Responses So Far. »

  1. Pseudo-code is such a great design tool. What I’ve found most useful is to use Python or Ruby syntax (you’ll additionally get good syntax highlighting too).

  2. I also find that visualising the problem helps out a lot, actually drawing a linked list for example and stepping through it with your pseudo-code.

  3. […] a post from Nick Halstead on the Programming and Management Blog, he discusses something just about every developer is […]

  4. I don’t have time to pseudo code..

  5. I use a slightly different technique, but solves the same problem in a very similar way. Starting from the top, I create a function or procedure stub for each main step, and write a main driver to call each of them in the right order. Then, for each stub, I flesh it out by writing new stubs, until each stub represents a simple step that can be described in a single line, and is likely to be coded in 2-10 lines of code. It’s top-down design, it uses stubs instead of pseudo-code, and doesn’t require the pseudo-code-to-real-code conversion.

    I’d only revert to pseudo-code if a complex algorithm to solve some particular problem was required, which in the kind of stuff I’m writing (business logic in PL/SQL) is pretty rare.

  6. […] code I have previously done an article on Pseudo code and I recommend you to read […]

  7. […] http://blog.assembleron.com/2007/06/03/uses-of-pseudo-code-in-development/ […]

  8. am trying to do a project.my project is to convert the psedocode to a program.
    can u give me any tips for tha plz.

  9. I need apseudo code to find &print all prime factores of a non negetive integer

  10. i need apseudo code that find &print all the prime facter of a non-negtiv integer

  11. great i luv it 10/10 i luv it

  12. i luv it mmm i just luv it

  13. I despise pseudocode. It only has ONE use I can think of and that’s for making a program in other languages. But even then, if you have the instructions for what is required (problem statement), then you’re ready to start coding in any language. Ultimately, I think the best way to write a program and develop the skills necessary, is just get in and do it and test your code at regular intervals for errors. Do you really think Microsoft developers sit down and write millions of lines of pseudocode before writing the final draft. That would just cost them thousands of extra man-hours.

Post a Response