Structured Programming
Keyword | Definition |
---|---|
Procedural programming languages | Languages where the programmer specifies the steps that must be carried out in order to achieve a result |
Imperative programming languages | Languages based on giving the computer commands or procedures to follow |
Hierarchy | A diagram that shows the design of the system from the top down |
Structure chart | Similar to a hierarchy chart with the addition of showing how data are passed around |
the system | |
Top-down approach | When designing systems it means that you start at the top of the process and work your way down into smaller and smaller sub-processes |
System flowchart | A diagram that shows individual processes within a system |
Pseudo-code | A method of writing code that does not require knowledge of a particular programming language |
Naming conventions | The process of giving meaningful names to subroutines, functions, variables and |
other user-defined features in a program | |
Dry run | The process of stepping through each line of code to see what will happen before the program is run |
Trace table | A method of recording the result of each step that takes place when dry running |
code |
Hierarchy
Hierarchy diagrams can be used to break down what happens in a program and where. An example of this is seen below:
-
Program
- Initialise
- Input
- Capture form
- Enter data
- Validate
- Process
- Output
The program is split into its functions, and then those functions are broken down further. In this example, the input program has three functions which do several things separately.
Naming Convention
This is very important to have practical and professional looking code. Using relevant names also makes it easier for the programmer to navigate his/her code: Int_num_Constant = ....
Code Layout
Some programming languages make use of white space (indentations) in there language like if
statements and loops. Indents are also used to show where the code belongs in the hierarchy. Code should also be commented to explain what each part does and in what way it is useful.
Pseudocode
Pseudocode, like flowcharts and trace tables, is a way of writing out code or planning ahead for what a section of code will be like, before it is written. Writing pseudocode is easy and very readable. There is no set syntax as long as it is consistent.