Importance of Pseudo code
Often times, whenever we start on a project, we want to jump right in. We want to start coding, writing, cooking, drawing, and when we do, our minds might go a mile a minute. This burst of dedication drives us to complete whatever is on our mind and yet, it is because of this burst of dedication that can blind us to see the overall picture. We can write hundreds of lines of code, but if we don’t achieve our goal, all the time spent would be for naught. This is where Pseudo Code comes in.
What is Pseudo Code?
Pseudo code is essentially a description what the logic should do. Similar to creating an outline or making a rough sketch, pseudo code should be written before creating the actual logic.
How to write Pseudo Code
Because Pseudo code is syntax-free and thus not compiled when running the application, you can use plain English when writing pseudo code. However, there are two schools of thought on how pseudo code should look like:
//If A is greater than B, then you should subtract C from A
//Else if B is greater than A, then subtract C from B
//If both are not true, don't subtract C from any
This one is in plain English. Anyone can determine what is going on, even if they have little to no knowledge of programming.
//if (A > B), A - C
//else if (B > A), B - C
Although this example is also in plain English, because it incorporates programming syntax into it, it might make it harder for those with little to no knowledge of programming to determine what is currently going on.
Why should I write Pseudo Code?
- Creating a layout of what you want to achieve: By writing pseudo code, you’re laying the foundation of what the logic should be doing when you’re done.
- The point between your mind and the computer: Sometimes, we know what we want to do but don’t know how to achieve it. By writing pseudo code, it allows us to jot down our ideas so, in the future, we can incorporate it into the logic. After all, you’re just “translating” the pseudo code to actual code.
- Easier to debug the logic: It helps out in two ways. First, it helps by ironing out the logic even before we start writing code. If something seems off when writing pseudo code, then it’s likely will cause a bug when writing code. Second, it can help pinpoint where the bugs are after compiling. For instance, if the player movement is off the mark, pseudo code can help us focus on the part that might be incorrect rather than going line by line.
- Better communication: If you’re working in a team that has members who may not have a deep programming background as you, it’ll make it easier for them to go through your code almost step-by-step and determine what is going on.