Journal 06 — Why Pseudocode?

Chris Nielsen
3 min readApr 25, 2021

--

I’m assuming at some point in your day you have some ideas pop up for a great app or a game.

Where should you start?

What does the code ultimately need to look like?

Should you just dive right in?

Consider gathering your thoughts in pseudocode, which is basically a series of statements in a particular pattern/flow that describe what you want to happen. From there you can start to piece together the functionality by researching the required code to achieve your goals.

There is no “right” way to prepare pseudocode. You can consider terms such as the following to help identify certain logic that should be required: If-Then, Input, Output, While (true) Do this, Repeat-Until (something).

Here’s a brief example where we are trying to calculate the area of a circle from the radius that is adjustable. We prepare some brief statements on what we are trying to achieve and the area of a circle calculation from geometry.

Create a calculation for the area of a circle
C# create variables and equation that can be updated in real time
Results in Unity to see functionality

Here’s another brief example on the cost of something with a tip included. Similar to the above example, we provide a description of what variables we need, along with the calculation, and we also include a specific output format we are looking for.

Pseudocode to describe a calculation of a bill plus tip
C# variables for calculating tip
C# calculation for tip and total cost
Unity example outputs from tip and total cost calculation

While researching the C# calculation and how to develop a user-friendly output, I had to use specific formatting for the currency values (which is where the .ToString(“C2”) comes from), which are described here. You could include even greater functionality in the program for different regions by adding System.Globalization to the Namespace to add functionality for different world currencies.

Thank you for stopping by!

--

--

Chris Nielsen
Chris Nielsen

Written by Chris Nielsen

An Engineering Manager consultant who is seeking additional skills using Unity 3D for game and application development.

No responses yet