Unity/Programming Analysis
Why you need to be writing pseudocode
A quick analysis about the importance to write down pseudocode before programming
--
Have you ever tried to start programming a function or feature for your development project and then all of a sudden you find yourself stuck in a line or part of the process without remembering what were you going to do?
Well, if you had pseudocode before started programming I can assure that you wouldn’t be trying to remember what was the next step to code for the function.
Pseudocode is a description of the steps that an algorithm will cover. As it’s a syntax-free description, it’s a good practice to write pseudocode using comments in the code or in another easily reachable medium.
For example, if I needed a function to limit the space where a player in my space shooter game in Unity can move I’d need to write the next pseudocode:
This way, I can think in each individual condition, variable and possible result when the function is executed. Instead of looking into a flowchart I can easily read my pseudocode and get the idea that I need to remember.
Once I finish with the function I can erase the pseudocode or use it to leave comments about what the function does, so that every other developer that reviews the code can easily find out what’s the purpose of the function in the project.
The function works and now the player teleports to the other side if it reaches the limits of the space:
And that’s it, you should start writing pseudocode before programming in Unity or in any other program! :D. I’ll see you in the next post, where I’ll be showing how to instantiate and destroy gameobjects in Unity.