Programming Tips: How Pseudocode Helps
Programmers love getting stuck in; finding a problem within some code, or finding a novel way to resolve an issue. Throughout my life, I’ve done a lot of scripting, coding and otherwise. I’ve developed a functional Excel-based system for my full-time employment, used across the whole organisation. I’ve previously created scripts for games like Minecraft and more – But until this week, I never thought about how I do it.
Regular programmers reading this article may roll their eyes at the thought, “Another novice programmer hacking his way through problems.” It’s not exactly unheard of, as a lot of people just get stuck in without proper planning. It’s true that there’s no better way to learn than by doing, but sometimes you need to step back and consider what you’re doing. The past two weeks, I’ve been writing more Pseudocode than ever before – And here’s why:
Pseudocode doesn’t follow any set conventions, not really. It instead can be anything that the programmer can read and understand. Thus, some programmers, when writing their own sets of pseudocode, simply write down what they wish to accomplish. Other programmers may make doodles, or create charts, or anything else that helps them.
Me? I like to mix up English with coding logic.
I’ve simply come to call my style “Logic English”, which is a daft name all things considered. Using this Logic English, I can begin from the very start. I can place myself in the users shoes and write about my experience for the program that I’m about to start writing. But this can be a daunting task, so where do I begin exactly?
Typically, I like to look at what system is affected. To me, the start is centred around the system itself. Will users be editing a database? Are they going to submit emails through the application? Do they need to have different access roles? What is the system that’s being accessed and how does the software interact with it? These are all questions to ask yourself as you begin to write your pseudocode.
The single most important element of writing good pseudocode, is simply to find faults in your logic. Oh sure, your logic may be nearly unfaltering, but when it comes to applying logic to a program, that can go out the window. The slightest misstep in your code means you’ll end up stuck trying to figure out where you went wrong for ages – And that’s not just me being dramatic. Rather, it’s almost a guarantee that if you don’t get it right, unless you are trying your code as you go along, you’ll have a lot to go through.
So when you start to write out your program in pseudocode, consider a few factors, such as:
- Does the pseudocode focus on the most sensible steps?
- Is the pseudocode easy to understand to you?
- Is the pseudocode easy to understand to a non-coder*!
- Does the pseudocode separate each part of the program in easy to understand chunks?
Ultimately, the whole purpose of this code is to give you an edge when developing your software. You don’t want to write something that, ultimately, doesn’t work at all. Programming errors can be corrected, but your code should always focus on delivering the content you need. For instance, you can code a button on a GUI to give users a contact form, but how do users even get to said contact form button?
There’s a third useful reason to write pseudocode and it’s related to bullet point 3.
Talking Out Your Code
Not quite as important as the other reasons for writing pseudocode, this is the stage when it’s all written. Perhaps as you’re going along, you want to hear what other people thing. So you work through it with someone. You let them know what your goal is, then you talk through your pseudocode with them. If they’re into computer logic, even if they’re a non-coder, they should be able to get it. And if they aren’t, figure out what’s confusing to them.
*Although talking it out really isn’t a necessity, it’s honestly one of the best ways to get honest early feedback. If you’re like me, you might make things too complicated from the offset, when someone comes up with a better solution much easier.
This may not have been the most exciting of subjects in the grand scheme of things, but it’s so overlooked. Naturally, there are almost limitless ways to do pseudocode, depending on how you work – So I must throw the question back to you. How do you do pseudocode? Do you even pseudocode?! Have you ever considered the use of it? As ever, we welcome your thoughts and opinions below, or over on Facebook and Twitter.