Psuedocode is a common practice used by good programmers to plan out their code.
It is a notation or a method of writing down programming concepts in plain language rather than in code syntax.
In practice, programs written out in pseudocode look a lot like recipes!
You've probably seen pseudocode more often than you think.
Check out this pseudocode for making an omelette:
- Crack and beat eggs in a bowl.
- Grease a frying pan and turn on the stove.
- Pour eggs into frying pan.
- Fry eggs until solid.
- Flip omelette.
- Fry until done.
Pseudocode provides the structure or outline of your code. Note that the above pseudocode includes the ingredients and the process, but omits specific measurements. How many eggs? How long should we fry the eggs for? What size frying pan should we choose, and how high should we turn on the heat?
Pseudocode for a very basic program to drive the robot straight and turn right could be as follows:
- Drive straight for 3 seconds (or 3 meters).
- Turn 90° to the right.
- Stop driving.
You can write out this pseudocode on paper before you begin to add blocks in the CoderZ Code Editor.
What might the pseudocode be for driving the robot in the shape of a square? What about pseudocode involving sensors?
Once you have your pseudocode, it makes it much easier to start writing your program.