Pseudocode Is Life

Intro

Pseudocode is the life-blood of strong code. Whether you are creating a huge database in Python, or utilizing JavaScript to create a hang-man game, pseudocode is your greatest tool. It exists as a guide to your code, as well as aiding in the organization and structure of D.R.Y. code. Pseudocode is the first step in creating quality software, and is absolutely necessary in terms of thinking through each step of the problem that is computational thinking/problem-solving.

What is It?

Pseudocode, by definition, is "a notation resembling a simplified programming language, used in program design." In normal language, this means that pseudocode is writing out your code in normal English. However, pseudocode is more than just writing out your code. It is thinking through the whole process of coding, from any questions you have, to project management basics (think MoSCoW), to the organizations of objects and functions, and more. Pseudocode is immensely valuable as a tool to express your thoughts about a project without providing any code.

For example, this past week I was given a project to design a functional Tic-Tac-Toe board. In the assignment, we always start with pseudocode. The first thing I did when I started my pseudocode was the first thing I thought to myself: Questions! Whatever questions I had about the project (how to display the UI, how to show symbols upon click, what functions I needed, etc.) were all quickly listed out. This serves as a great guide for your thinking and ensures you have a clear image of what you understand and what you do not. From there, I would break my pseudocode down into three sections: procedural (what I needed to do step-by-step), functional (what functions I needed), and object-oriented (specific objects/code I could later optimize). The procedural is usually a little rougher, and includes steps that I end up changing several times by the end of a project. That's one great thing about pseudocode: it exists as almost a sort of “rough draft”. It can always be edited for clarity and readability later, but initially starts as a sound board for your own thoughts about a project. When I first started designing my Tic-Tac-Toe board, I wanted to use an object named Game and then include all my other functions and methods within that object. Including all of my code within one major object seemed reasonable and accessible at first, but as the project went on, I found that I did not (yet) have the technical knowledge and skills with object-oriented programming to be able to complete the task that way. Instead, I ended up breaking the code down into smaller functions and staying away from using objects. I used mostly array methods and arrays to accomplish the various tasks within functions. The pseudocode helped me to get started, but I ended up diverting away from my original plan. And that is ok! Pseudocode is not final, but is rather meant to be a starting point and a draft that can be readily accessed and edited.

So What's the Point?

Pseudocode is so vital to programming. When I first began coding, I thought of programming as a simple exercise of rote memorization. You just have to remember what these various key words mean and their syntax. My lack of experience left me ignorant. In reality, coding is about problem solving. It is all about being able to take a huge project, a huge problem, and break it down into manageable step by step problems. Then, solving each problem to complete the overall task. Without pseudocode, we are left trying to organize all of our thinking and problem solving strategies in our minds or on paper. Pseudocode provides an avenue to think through all of these problems and work concretely to discover solutions outside of the programming languages themselves. Only then can we take our pseudocode and sandbox it into the appropriate languages, and continue utilizing trustworthy resources like MDN-Docs to find answers to whatever may be missing. Pseudocode is also necessary for communicating between different parties. I can share my Tic-Tac-Toe pseudocode with a Python developer, and even though I wrote my code later in javaScript, they can still get the general idea of what I am trying to accomplish. Pseudocode helps to translate ideas across different developers with different technical backgrounds. Because pseudocode is language neutral, I find it really helpful when trying to think through the logic of a project. I really struggled during the Tic-Tac-Toe project to get started with the project. I wondered for hours: “How does the computer know when someone has won?, “How can I display the symbols when the different players click on each tile”, and even “How do I ensure the tiles can’t be clicked a second time due to user error?”. Pseudocode providing me the space to think through these issues and try to make sense of the logical code I would eventually create.

Conclusion

I love coding. It is fun, and exciting to get the immediate gratification of change on a page. Nevertheless, pseudocoding is the heartbeat of great software development. Without it, we would not have the means to communicate across different programming languages, and work through high-level problem analysis. In summary, pseudocode is vital to the success of any programmer. It is the starting point of thinking through a problem, regardless of the language used. Yet, it is more than just the starting point. It represents your brainstorming, your rough draft, and even editing/proofreading of finalized code. I think of pseudocode as a lesson plan for a teacher. It should give you everything you need for a project, much like how a lesson plan document should give a substitute teacher everything they need to teach on the Crusades. Now, before you begin coding next time, stop and remember your pseudocode!