Pseudo code: step-by-step
Programming is just telling a computer what you want it to do, however, this is not as easy as it sounds.
To be able to talk to a computer we need to talk in a language that it understands. We can’t just walk up to it and say, ‘make a cup of tea’, as it will just ask us, ‘what is tea?’ We need to break down each step, define each ingredient and explain every method.
Imagine a scenario where the year is 2021, Earth has made first contact with aliens and you have been chosen to ‘teach them how to make a cup of tea’ (the British way).
To you, this task may seem trivial, but to the alien, the idea of tea is completely foreign. They have no concept of tea, milk, sugar, kettles, electricity and will have no idea what you are trying to explain to them. So what steps do we take first?
Defining your programs intentions and steps
First, we need to decide why we are trying to tell the computer to do something. For our program (or alien tea tutorial) we need to be defining the program’s purpose. For this scenario ours will be ‘to make the user a cup of tea’.
Next, we need break down our program to the absolute basic steps and questions that the computer can understand and, therefore, create the desired output. One method of doing this is converting our instructions into pseudo code. This is a way of informally laying out the design of the program without doing any actual programming. Pseudo code acts as a bridge between plain English and programming code, making it easy for humans to interpret. It’s best to do this in the early stages of the design.
For our tea-making example, the pseudo code would look something like the following:
- Put the tea bag in mug
- Add water
- Add milk
- Add sugar
Now consider you’re teaching the alien how to make a cappuccino (the barista way); a slightly more complex process.
Identify the steps you would write into the pseudo code and post your design in the comments area below.
© Coventry University. CC BY-NC 4.0