When learning programming it is important to remember that ultimately the programmer not the compiler is responsible for making heads or tails of the code that they’re writing. The compiler will run any sort of code good or bad as long as it’s syntactically correct.

This leads to one of the many pitfalls that plague software engineers is getting hung up on the idea of syntax at all costs. When designing software it’s important to understand the underlying flow of logic in your programmer whether it’s a game or the guidance system of a Tomahawk cruise missile.

One of the many tools in the box is pseudocode, this is half-English, half-code that helps you look at the flow of a script or project at quick glance when writing your code.

The best example that comes to mind is it easier to write a comment saying “This makes a pyramid 10 rows high and 12 wide at the bottom” or is it easier to read a method with a for loop that iterates over and over named “Pyramid”? I don’t know about you but I’d take the comment instead of mentally trying to build a pyramid.

In Unity this manifests as well commented code. Below are two examples with and without pseudocode for a simple movement system and firing system for Atomic Shooter.

Uncommented Code

Commented Code

As you can see one is much more legible, clear, and easier to understand. This helps reinforce a key method of programming, iterative design. You start abstract and iterate over and over writing code until you reach the detailed conclusion.

By starting a projecting in pseudocode you can create a high level abstraction to refer to as you building out parts of your program. Then you can convert the pseudocode into proper comments for each of your methods and classes, as opposed to writing the comments after you write the code. This helps you catch problems in the structure of your code earlier.

You can also make changes more easily as changing out some pseudocode is often way easier than rewriting a ton of code that might break. This makes doing code reviews a snap as you’re not getting bogged down in syntax reasoning and instead focuses on the core logic.

Hopefully this article has shown you the value of starting your coding with a pseudocode outline and then filling in the detailed and well-reasoned code you need to make the program as you intended. Until next time, happy coding.