A Pseudo-code is a clear and simple group of sentences or list items, explaining all the basic steps a function should follow in order to accomplish a bigger task. A pseudo-code can be expanded to develop an algorithm, as well as to develop other sub-pseudo-codes.

Pseudocode is an informal high-level description of the operating principle of a computer program or other algorithm. It uses the structural conventions of a normal programming language but is intended for human reading rather than machine reading. [1]

Let’s examine a simple pseudo-code for the hangman game:

  • Pick a random word
  • Display a field for all letters in the word
  • If the user has lives left
    • Let the user pick a letter
    • If the letter exists in the word
      • Show the letter on the place
      • If the number of letters found = word length
        • Game win
    • If the letter doesn’t exist in the word
      • reduce user lives one point
  • If the user has no more lives
    • Game lost

As you can see, pseudo-code should be clear and precise. It is written in plain English, and simply summarizes what to do on each step. Then, the developer can easily convert this code into any programming language, whether it should be a desktop app or a website. It is just like a universal language between developers.


How to Write Good Pseudo-Code

Writing pseudo-code is not really a hard task, but you should always consider the following while writing pseudo-codes;

  1. Use a plain text editor – Nowadays, I really like Dropbox Paper editor but you can use any text only editor like notepad.
  2. Give it a title – When you start with a title, it will be easier to stay focused.
  3. One statement per line – Your sentences should be short and clear, don’t mix two tasks into one line.
  4. Use indentation for blocks – For conditionals and loops, use indentation to group sub-tasks.
  5. Explain every little step – So that nothing is left to the imagination of the developer.

Conclusion

I hope you liked this little introduction for programming. I really like using pseudo-codes because they are like breadcrumbs trails to the finished programs and they can be translated into any language easily.

Please follow me on Twitter for more posts like this.

References