C#: Psuedo Code
…Why programmers should write psuedo code within their real code.
Pseudo code is another term for making comments within one’s code in order to help explain what is going on within a program. This can be for the benefit of the sole programmer or for the benefit of others who analyze one’s code. When programs grow from a couple hundred of lines to tens of millions of lines, it is helpful to add comments that help translate computer logic in code into grammatical phrases and sentences.
For example, below is a section of the script from the previous Simple Player Movement tutorial.
We have a transform.position equation in one line of code. Above it, you can see there is a line of code preceded by //, double forward-slash. The double forward-slash creates comments within C# that do not affect the program. This comment mirrors the line of code that follows. The following images show how the logic is broken down in the comment.
The comment functions as our pseudo-code. It is a readable phrase whose logic reflects that of the actual code.
Of course, this is a simple example. It is helpful for those beginning to learn how to program, but it may not be needed for simple commands as these. However, as code becomes more complex and numerous classes are being referenced, it is important to write out logic so that you and others may understand it at a later time.