Pseudo Code: Why?
A quick look at pseudo code and why it should be a best practice.
What is pseudo code?
Pseudo Code is like writing down what you want your program to do in plain words. You don’t have to worry about technical stuff like syntax or code rules. You just have to explain what you are trying to accomplish.
Benefits of Pseudo Code
- It’s easy to write and read, because you are using your own language and style.
- It’s flexible and adaptable, because you can change it as you go along.
- It works for any kind of program or algorithm, because it doesn’t depend on any specific language or technology.
- It helps you plan and design your program or algorithm before you write the real code, which can save you time and hassle.
- It helps you share your program with others, like your teammates, clients, testers, or users, who may not know the coding details.
- It helps you find and fix any mistakes or gaps in your program or algorithm, because it shows the logic and steps clearly.
How to write pseudo code
There’s no right or wrong way to write pseudo code, as it’s just a way of expressing yourself. But here are some tips to make it clear and consistent:
- Use Simple and descriptive words that anyone can understand.
- Use spaces and tabs to organize your code into chunks and sections.
- Use words like IF, THEN, ELSE, FOR, WHILE, REPEAT, UNTIL, etc. to show the flow of your program or algorithm.
- Use comments to say what each line or chunk of code does.
- Use variables and constants to store and use data values.
- Use pseudo code statements to do calculations, comparisons, assignments, input/output operations, etc.
Example of Pseudo Code
Here’s an example of pseudo code that figures out the area of a circle given its radius:
As you can see, this pseudo code is easy to understand and follow, even if you don’t know any programming language. It also shows the logic and steps of the program clearly.
Summary
Pseudo code is a handy tool for programmers and developers. It’s a way of writing code that uses plain words or a general structure of a programming language. It doesn’t have any technical stuff like syntax or code rules, making it easier for yourself as well as others to understand the logic and steps of the program or algorithm without knowing the specific programming language. Next time I will be discussing Instantiating & Destroying GameObjects in Unity.