Skip to content

Using pseudocode to develop algorithms

2009 May 22
by Richard Knop

I am used to jumping right into programming and just come up with algorithmical solutions on the go but lately I’ve been playing a bit with pseudocode. The idea is simple. Before you start programming, you write the algorithm down in a simple informal language – pseudocode.

The pseudocode usually uses some conventions from normal programming languages (like if/else, while, for and other statements) but things not important for humans are omitted – the aim is to describe the algorithm in a way clear to humans not machines. Here’s an example of my pseudocode:

get the latest articles

for all articles
    if article is published
        write title
        write content
        write number of comments
    endif
endfor

As you can see there are no rules. No variables declarations and no system-specific code. Personally, I like to use if/endif, for/endfor to make the code more readable.

Why use it? It can save lots of time as translating algorithms to a specific language is much easier when you already have all business logic described. There’s also a chance you will find and fix potential issues before the real programming.

2 Responses leave one →
  1. Matus Laslofi permalink
    May 23, 2009

    This is a very good idea! I’ve been drawing my ideas on a piece of paper before coding more difficult projects. But so many times I just got lost in my not-so-state-of-art drawings. I’m going to use this indeed. Thanks!

  2. May 23, 2009

    Once you’re done you can just comment the pseudocode lines and write the real code in between them :)

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS