Building complexity in your design
The next step of making a program is breaking down the processes of the program into a medium that is easy for you and anyone else reading it to understand.
One medium that you could use is flowcharts. This is a more visual and structured way to represent the steps of a program. By ‘steps’, we mean the different actions and decisions that will be made. They also make it easier to visualise any errors that you may encounter later in the program.
The easiest way to get started is to copy over the steps from your pseudo code and place each one into a block in a flowchart, as in the example below, which continues the tea-making scenario. The flowcharts below use an internationally recognised set of symbols.
Now you have the basics of the program design ready to work with, it’s time to look at the additional, more complex steps that were lacking in the pseudo code. We need to ask questions within the program like has the kettle boiled? Do they want sugar? Do they want milk?
In the step above, we have added some decisions (diamond shape) and a loop. The decisions branch off depending on the answer to the question. Like in this example, we ask if the user wants milk. If they do, we add milk. If not, the program continues onto the next decision point.
We can also create loops, where we can halt our program until a condition is met. We do this when checking if the kettle has been boiled at the start of the program. This part will run forever until either the program is stopped or the kettle is boiled.
But is there any water in the kettle to boil? How much milk and sugar does the user want? Questions always lead to more questions, which helps you expand your program design to account for more and more conditions.
Notice how, just by asking ourselves questions, we have expanded our five-step pseudo code into a pretty solid program design, whilst maintaining a simple structure that the computer will be able to understand when we finally start converting our design to code.
Asking questions is one of the main parts of programming. You may even go as far as to ask, ‘have you paid the electricity bill so the kettle can boil?’ It may feel silly going into this much detail, but this is what programming is like. The more decisions we implement and account for, the more fool-proof our program will be. We have to remember that the computer can only do what you tell it to do.
Review our tea-making program above and consider what other conditions we may need to account for in the design.
Identify at least five different steps/decisions that could be added to our program to improve it further and discuss with your fellow students in the comments area below.
Gliffy. (2020, November 15). Guide to flowchart symbols, from basic to advanced. Perforce. https://www.gliffy.com/blog/how-to-flowchart-basic-symbols-part-1-of-3
© Coventry University. CC BY-NC 4.0