Why you need to be writing Pseudo Code
Pseudo Code — What is it?
Pseudo code is a tool for planning out your coding objectives. Think of it as an outline of what you plan to accomplish in code without all the formality of syntax.
How to write pseudo code?
To write pseudo code, enter single-line or block comments in your script.
- Single-line comments are preceded by //
- Multi-line comments are encased in /* … */, replacing “…” with your comments
When writing pseudo code, keep the following steps in mind:
- Determine what you are trying to do
- Outline step-by-step how to make it happen in comments
- Follow your pseudo code to fill in your script
- Test your code and verify the results match your expectations
- Remove your pseudo code
If you were trying to set up player movement in a top-down 2D game, you might write the following pseudo code:
Why use pseudo code?
Ever try to write an essay without some kind of plan? How about an essay in a foreign language? Well, that’s kind of what programming is — translating tasks in a specific step by step fashion that the computer can understand.
First you have to figure out the logical steps to accomplish the task (via pseudo code), then write them in command the computer can interpret. If you free-write your code, it’s easy to lose focus on the task at hand.
When it comes time to test your code, imagine if the results aren’t what you expected. First you’ll have to review each line of code to first determine what you were trying to accomplish, then determine why it’s not working as expected. If you use pseudo code, you can review the logic in the pseudo code and compare the code you entered to your pseudo code to determine if it is correct.
In the end, it comes down to two questions:
Would you rather start programming with this:
And would you rather troubleshoot this: