We’ve looked at Flowcharts as a way to visually show and describe the steps of an algorithm to solve a problem. It does a great job of that, yet there are two issues.
The first is that some people are not visually inclined. They don’t care for the visuals, and feel it gets in the way.
The second is that the shapes and flowlines can cause complex algorithms to get very large, and hard to follow. A Flowchart that would take 3 or 4 pages to print out would be tough to work with. Of course, predefined processes that you create, will definitely help, but it’s not perfect.
So for those who prefer more of a textual methodology, or for those complex processes, I would like to offer you – pseudocode.
What is Pseudocode?
Pseudocode is natural language text, that is like (hence pseudo) code. Natural language is any regular spoken and/or written language – usually the language that the developers are used to using. In the US, we’d use English, however if you were in a different country, you’d use their native language.
This allows you to write out what you want to have happen, without having to know an actual coding language. In fact, you can design your algorithm, without knowing which language will be used. This helps developers start to work on solutions while other decisions are being to be made.
How Language Specific is Pseudocode?
Because it is pseudo-code, it is not exactly like code. There are not specific words or phrases that need to be used. It needs to describe what you want to accomplish in a manner that is detailed enough for the developer to be able to code the solution.
This means you don’t have to commit to a standard series of keywords that will be used, however, you will often find the same words being used over and over as it makes sense to other developers as well as non developers.
How Detailed Should it Be?
This is the most common question people ask. Some people feel that one line of code should be generated for every line of pseudocode. This makes it feel like another language, which can be frustrating. Others will feel it is more of an abstract method, and one line of pseudocode can be tens, if not hundreds, of lines of real code.
The reality of it is that it’s probably somewhere in between. As a new coder, you should probably focus on writing more specific pseduocode that is closer to what you will write as a programmer. As you get more experience, you will know how to fill in gaps automatically. Until then, use this experience to help you work on your problem solving skills.
Why Not Use Pseudocode?
Because it is “text based” some people may not like it, preferring the visual concepts of a flowchart.
Also some people may not like to write out content, feeling like it would be better to just write the code. However, this group is often writing out too detailed of pseduodecode, and by being a little more abstract, it won’t feel like double the work.
Where to Write Pseudocode?
You don’t have to use any special software to write pseudocode. You can use anything from Google docs to MS Word to Notepad. I actually use my code editor Visual Studio Code, a lot of times as it is simple, and I’ll take my pseudocode, and use it at comments (internal documentation) which lets me know what actual code I need to create. But that’s my method, you may find something else that works for you.
An Intro to Pseudocode was originally found on Access 2 Learn
2 Comments
Comments are closed.