Fake Code, also known as Pseudocode.

Christina Larsen
4 min readNov 16, 2023

--

Just so we are clear, Pseudocode literally means “fake code,” but to make the program we want to build work, we need an actual programming language like JavaScript, right? So why mess with a “fake code?”

Computer programming or coding uses a rigid language that does not allow for mistakes. You need to be meticulous about where and how you use your semi-colons, curly braces, DOM methods, and all other core language principles if you want the program to work.

Have you been given a complicated assignment, and you sat there for what felt like forever trying to decide how to start? This is where “fake coding” can be beneficial. Pseudocode is a way of making logical instructions (algorithms) into a form most people can understand, regardless of language. This is because all you must do is explain what you want to do. It’s informal, with no syntax and very few rules.

The benefit of the informal language of pseudo-coding, especially for students, is that it takes the rigidity out of the equation for a few minutes. Most people know how to give directions; an example teaching a child how to make a peanut butter and jelly sandwich:

  1. You need 2 pieces of Bread, Peanut Butter, Jelly, and a Butter Knife.
  2. Place the bread on the table side by side.
  3. Open the peanut butter and use the knife to get the peanut butter out.
  4. Spread the peanut butter on one slice of bread and close the peanut butter jar.
  5. Open the jelly and use the knife to get the jelly out.
  6. Spread the jelly on the other slice of bread and close the jelly jar.
  7. Put the 2 slices of bread together so the peanut butter and jelly touch.
  8. Eat the Sandwich

Straightforward and simple, right? You can use the same principles to break down what you need your code to do, allowing you to think logically about the program flow without worrying about the syntax for the moment. There are some things to think about, though, that will help you in your writing.

  • Make sure you understand the problem you are trying to solve. If what you are looking at has more than one problem or different parts to the problem, break them down into smaller sub-problems so they can be examined individually.
  • Keep it simple, but avoid ambiguity. By this, I mean using clear, precise language while being as specific as possible. If something doesn’t seem clear, use comments on what you’re trying to do. The point is to understand the thought process you are using when you go back to do the actual coding.
  • Using standard conventions, like if, else, or for, in your pseudocode, along with descriptive variable names, such as userInput or totalSum, will help give you a better skeleton to build your actual code.

How does pseudocode work? We will take a look at a simple problem below:

  • Write a function that takes in a string and outputs the number of vowels (not including Y).
  • Ex: Input: “Sweet Nightmares” = Expected Output: “5”

Pseudocode:

Actual Code:

Yeah, I know, it’s very awkward at first, but it’s that way with anything you are learning, and it does get easier the more you do it. I, myself, have found it to be beneficial as my assignments in school get bigger and more complex. That’s why I think it’s an excellent skill to learn.

Also, many employers use pseudocode-type tests for interviews to test the problem-solving skills of an applicant. In this industry, problem-solving skills are much higher on the importance list than being able to code. You will probably also find yourself in a situation where you need to explain what the code does in plain English to a coworker or boss who doesn’t know the coding language.

In closing, pseudocode is a great skill to learn as it can help you in many ways in your professional life.

Check out these other articles:

What is Pseudocode? How to Use Pseudocode to Solve Coding Problems (freecodecamp.org)

--

--

Christina Larsen
0 Followers

Greetings! I'm Christina Larsen, a recent graduate of the UC Berkeley Extension Full Stack Web Development Certification course (December 2023).