Pseudocode is Pseudoright

Pseudocode gives us advantages in programming

Image for post
Image for post
Photo by Clément H on Unsplash

Developers listen. Stop that. Drop the ramen. Listen. Look at the screen. Come on.

I’ve got a secret for you.

Pseudocode helps code quality

Don’t tell everyone. Let it be our secret.

Prerequisites:

  • Coding experience in some language would be useful

Terminology

Pseudocode: A simplified human-readable programming language

What is Pseudocode?

Pseudocode is a human-readable description of what code actually does. By leveraging the English language, Psuedocode makes it easy to understand the meaning of programming code without the use of a computer or even a particular programming language.

The idea is, even if you have two programmers who don’t know the same programming language, they can still communicate through the use of writing algorithms in Pseudocode.

Image for post
Image for post

The idea is that the algorithm is easy to follow and understand.

On the first line a variable is set up with the number 1. We then initiate a while loop where num is output (printed) to the console.

Therefore the equivalent of this is Swift code shown below:

var num = 1
while num <= 5 {
print (num)
num = num + 1
}

which prints the following to the console:

1
2
3
4
5

Why use Pseudocode?

Pseudocode is a method of communicating code that does not rely on a specific language, and this therefore rather closer to English than existing programming languages.

Communication

Even if you are not aware of the complete capabilities of a language, you would be able to write code using Pseudocode and work through problems. It is even possible to do so without a computer, that is work out how code might look and work out bug without a computer at all.

That is to say, Pseudocode can be a companion method to using logic and working out bugs in code away from a computer, and changing a programmers approach to do just that. The use of Pseudocode can save development time, mean that developers use their time well away from a machine.

Language-independent

Pseudocode isn’t actually a programming language. Pseudocode can however be easily translated into concrete programming languages, and offers the ability for programmers to solve problems (equivalently) in a number of languages at the same time. Using Pseudocode means that development time is not wasted, particularly since the target language for a project can change during development!

Streamlined

Since Pseudocode is not specifically a codeable language, the process of using Pseudocode can speed the product development phase of coding since many of the distractions that are inherent in using a specific language at this stage are removed.

When using Pseudocode developers look at the whole picture, and develop a macro-view of the problem. This ensures that the problem is adequately defined and documented before coding starts in a particular language and tools up developers for the prototyping stage quickly as in those very early stages code did not need to be rewritten.

Efficient

Using Pseudocode means that an efficient development pipeline can be worked out with the planning stage a rapid component of this — simply because Pseudocode is used.

The whole process of software development becomes quick and economical, removing complexity from the planning stage of the software development process.

The Pseudocode Cheat-Sheet

Pseudocode is a wonderful thing to use, and a way of programming without a computer!

Variables

Image for post
Image for post

Operators

Image for post
Image for post

Loops

Image for post
Image for post

Selection

Image for post
Image for post

Arrays

Image for post
Image for post

Subroutines

Image for post
Image for post

Strings

Image for post
Image for post

Casting

Image for post
Image for post

Working through problems

Pseudocode can be used to work out non-trivial problems. One such problem can be sorting, and one algorithm that is famous is the Bubble Sort algorithm that works through a list swapping out of order elements to create a sorted list.

Without a machine at all, the following can be written as a Pseudocode interpretation of the Bubble Sort Algorithm

Image for post
Image for post

This can then be translated into Swift code (for example)

Now this is not an implementation I would use in Swift (that is covered in my Bubble Sort for Swift article), but this is not a problem with the Pseudocode process but is a problem with publishing this type of article.

Conclusion:

You might be familiar with pseudocode from a university course, or might even have developed your own pseudocode to help your own coding journey.

This article has formalised the idea of pseudocode and how this great tool can be used to help your programming and formalise it’s use in your own programming!

The Twitter contact:

Any questions? You can get in touch with me HERE

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store