As a programmer, it can be extremely easy to absorb yourself in your code while you are trying to debug what the heck is going on in your code. After all, you did think about your code carefully before you tried typing right… Well, the answer to that question should be yes regardless of whether you wrote down any pseudocode! However if you don’t know what pseudocode is, wikipedia says the following:
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.
Basically, pseudocode is written english that should be directly translatable to code! Now I don’t mean directly translatable in the sense that you would be able to write pseudocode and then plug that into google translate with your programming language of choice (though that sounds kind of useful…), I mean that your pseudocode should contain a basic description of how your code should flow and function. Pseudocode is often an algorithm, or a series of instructions, that really provides structure to what you will programming and how to do it. It is like explaining what you are trying to program without using programming terms. If you can’t explain in words exactly what you are trying to do in pseudocode, then don’t try to write any code yet! And once you have properly created your pseudocode, it should be pretty simple to convert it into actual code.
- Pseudocode presents a solution to a programming challenge in English (or whatever language you choose to speak in)! This pseudocode can then be understood by non-programmers and thus you, the developer, can involve non-programmers into the creative process that is coding.
- Pseudocode is language independent! Say you had a friend that was working on the same problem as you but didn’t know the same programming language, you would then be able to share your ideas through the pseudocode you prepared! Also, while you may only know one language while learning how to program, pseudocode is beneficial for when you know multiple languages and are spending time deciding which language you may want to use to solve your current programming problem.
- Pseudocode allows developers to properly allocate their time on a project and streamline the product development phase. You can be sure that you have adequately defined your problem through pseudocode, before diving too deep into the actual implementation and then realizing you have forgotten something important. You also don’t waste time correcting code that has already been written.
- Pseudocode increases efficiency in a project’s development process. Projects can be developed quickly and thoroughly through pseudocode. Catching errors while writing pseudocode is less costly than catching them later in the development process.
I wanted to show you an implementation of how to determine whether a word is a palindrome in order to show you the importance and usefulness of pseudocode. To determine whether a word is a palindrome, you just simply refer to the definition: a palindrome is a word that reads the same forwards and backwards. Okay… that’s a good starting point, but how can we turn that into pseudocode. We could simply write something like:
word == word.reverse
But lets say there weren’t a reverse method. We’d have to build off the definition then. Well, diving deeper into what a palindrome is, a palindrome is a word that begins and ends with the same letter. When those two letters are removed, the remaining letters form a word that can also be read the same forwards and backwards, or in other words, when the two letters are removed, the remaining letters form a word that is also a palindrome. Great! We have a nice pseudocode algorithm to translate into code!