The idea of structured programming is simply having an procedure or process that you can work through to devise and algorithm and write a program for any problem.
1) Break into Modules
Ignoring any unnecessary detail, break the problem down into modules (sections of a problem) so that they can be solved using subroutines.
2) Create Algorithms
Solve each of the modules using algorithms, noting the inputs, outputs and processes for each subroutine
3) Create Interfaces
Write up the skeleton structure for each subroutine only using the subroutine name, inputs (parameters) and outputs. This basic structure is the interface (it establishes how this subroutine will interface with other subroutines and the main algorithm).
def CalcAge(Year) return Age
4) Complete Subroutines
Use sequences, selection and iteration to carry out any necessary processes to complete the subroutines.
def CalcAge(Year) Age = 2018 - Year return Age
Advantages:
- Modules can be worked on and developed in isolation from each other
- Modules can be worked on and developed simultaneously by different developers
- Modules can also be tested individually to check that they work (it is far easier to spot errors in your code when they are tested this way).
- The finished programs are much neater and easier to understand
- Using parameters removes the need for global variables which can cause confusion when coding and make errors difficult to spot and rectify
Click here to download AQA’s detailed official explanation of structured programming.