Skip to Content

Writing pseudocode

Posted on February 02, 2016 by Susanne Kappler

For many beginning developers, starting a project may seem overwhelming, given the number of problems that need to be solved and the complexity of the code involved.

One way to make your project seem less intimidating is to write your application in pseudocode before starting to code. Pseudocode uses non-technical language to describe the steps needed to execute the application.

Let’s take a look at an example:

Our Javascript application requires us to determine the largest number in an array and log it to the console. We can already write two lines of pseudocode just based on that description without getting into the nuts and bolts of how the code works.

We also know that our function will finish by returning the largest number, so we can add the pseudocode for that. It helps to structure your pseudocode similarly to the eventual code, so the indentation of our pseudocode will match the indentation of our actual code.

Next, we take a look at how the function is constructed. Our function will take an array as a parameter. We will need to create a temporary variable that holds the largest number. Our new pseudocode looks like this:

Then we will loop over the array.

Finally, we will compare the numbers inside the loop.

Now that we’re done with our pseudocode, we can add the actual code.

Some of these steps may seem too detailed to experienced developers, but working with pseudocode (especially in large and complex applications) can help you not only in structuring your code, but will make it easier for other developers to understand your code. It also makes documenting your code easier since you can use the most relevant parts of the pseudocode as comments.