Design Techniques

There are a number of design techniques that we will cover in the Higher Course.

Flow charts are still acceptable for the refinements if you so wish but used on their own they cannot show data flow so cannot be the sole design method.

Problem Scenario

The Scot Fit Club wants a program to monitor the health of club members by recording their heights and weights and calculating each member’s Body Mass Index (BMI). The formula for BMI = (Weight in kilograms)/Height2

The BMI will be categorised as Underweight, Idealweight or Overweight according to the criteria below:

The details of club members held in a text file which stores the height and weight. 

File Structure

1.6,62.3

The program will then calculate and display a summary  of each Height, weight and BMI calculated as shown below:

Summary  of each Height, weight and BMI calculated

Then the number of people in each category should be displayed.

Pseudocode and Data Flow

If you choose to design using pseudocode then you must include 3 elements:

We will now look at the BMI program and create these.

Top Level Design and Data Flow

Refinements

1 Get Data From File

1.1 WHILE file.txt IS NOT BLANK

1.2 READ next line of file

1.3 SET newarray = split line on “,”

1.4 SET weight(counter) = newarray(0)

1.5 SET height(counter) = newarray(1)

1.6  READ next line of file

1.7 END WHILE

1.8 CLOSE FILE

And the data flow will allow us to identify the parameters being passed in and out.

2 Calculate BMI

2.1 FOR length OF WEIGHT array

2.2 BMI(counter) = weight / (height^2) 

2.3 NEXT LOOP


And the data flow will allow us to identify the parameters being passed in and out.

3 Create BMI Summary

3.1 FOR length of BMI array

3.2 IF BMI(counter) <18.5 

3.3 INCREMENT underweightTotal by 1

3.4 ELSIF BMI(counter) >=25

3.5 INCREMENT overweightTotal by 1

3.6 ELSE INCREMENT idealweightTotal by 1

And the data flow will allow us to identify the parameters being passed in and out.

4 Display Each Record and Summary Table

4.1 Output Headings

4.2 For each member

4.3 Display Height(counter) &  weight & BMI(counter) to 1 decimal place

4.4 NEXT Loop

4.5 Display 'Underweight' & underweightTotal

4.6 Display 'Ideal Weight' & idealweightTotal

4.7 Display 'Overweight' & overweightTotal

And the data flow will allow us to identify the parameters being passed in .

Structure Diagram Top Level Design + Data Flow

You will notice that each step of the main design roughly correlates with a function/subroutine - so that dataflow can be identified at this stage.

Data Flow Diagram

This can also be represented by a diagram similar to below.

This would allow us to establish the parameters that are going to be passed into and out of the subroutines/functions.

So for example one of the subroutines would be shown below:

def getData()

....

return weight, height()

You will notice that any parameters that are arrays are indicated by the use of brackets ( ) after their name. 

Each out parameter is essentially a return in Python.

Refinement - 1 Readfile

This is reading the file, processing it and storing it in two parallel arrays.

Refinement - 2 Calculate BMI

This is a straight forward calculation using the height and weight arrays to calculate the BMI (storing it in the BMI array)

Refinement - 3 Create BMI Summary

Refinements - 4 DisplayOutput

Interface Design - GUI

If using a Graphical User Interface then a suitable wireframe would have to be developed:

Even the interface of a text based program has to be designed and ensure that it demonstrates suitable input and output