Journal 06 — Why Pseudocode?
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.
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.
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!