written by
Marc Hewitt

Why You Always Start With Pseudocode

Unity3D 2 min read , April 30, 2021

For non-coders, I always explain Pseudo-code in the context of writing a novel.

Novels, like software, are massive undertakings with lots of parts and typing. Your Pseudocode is essentially your novel’s outline and then your rough first drafts.

These rough drafts help you quickly figure out what is missing to make it work. This also helps you figure out how big the actual novel is going to be for better project scoping.

Without Psuedocode you might build the wrong thing at first, wire it all up, and then have to waste hours untangling Spaghetti code.

To demo this in action let me show you what a student of mine ended up doing.

Demo of Pseudocode from my Student

Once a week I’ve been teaching Unity3d to a few 2d artists and this past session I got to actually showing them Pseudocode to help them overcome a code problem.

With this upcoming example, in 5 minutes flat we drafted out an entire mini-game of rock-paper-scissors. Then I was able to use it to teach them the basics of coding without them ever feeling lost.

We drafted 80 lines of pseudocode to help him make the minigame where he would not get lost. The final scene had 400 lines when he got it fully done! He never got stuck or lost even though he had never coded before.

The Pseudocode 1st Draft - the outline

Start simple by listing out what you want to have done, and the important steps.
In writing, this would be your outline.

A little Rock-Paper-Scissors game logic

This also generates almost a “Todo” list for you to check off as you work.

The 2nd Draft - Detailing it in

This draft is more focused on how you’d structure your code, the exact code doesn’t need to be fully correct and you can just throw in place holder content as needed to save time. Remember it’s a rough draft so we want to get just enough down to see potential issues.

Basically, take your outline from before and then fill in the blanks.

We’re using a special scripting language within Unity3d

The Third Draft - Catching Issues Early

We can now mentally run through it step by step, to see if we’re missing anything.

With my student, we found they actually wanted a “best out of three” mechanic but realized they forgot that in their outline. So we had to edit our draft with additional pseudocode.

I’ll save posting a huge wall of text again and simply show the additions needed.

Pseudocode for “Best of 3” round tracking

This works with large scale applications as well

Pseudocode is amazing not just for teaching! It is great in any project as a scoping tool, for finding issues early, and knowing what questions to ask “before” you start a large task.

No one, off the top of their head, can answer how long any given UI or API will take to set up. But by doing the pseudocode it can be broken down. Questions can be formulated to detail out an outline, and then the programmer can comfortably estimate each step.

So if your team is struggling with bad scoping. Get Pseudocode more involved in the planning phase.

unity3d tutorial programming