Software Design & Development: From Analysis to Evaluation.
1. Analysis, Design & Data
Analysis
The first stage: figuring out what the software must do.
Inputs, Processes, and Outputs (IPO).
- Input: Ask for length and breadth.
- Process: Calculate area = length * breadth.
- Output: Display "Area is 50".
What the users need/want (Usability & Constraints).
- Must be easy to read (clear font).
- Must load quickly (under 2s).
- Must run on school tablets.
- Must handle errors without crashing.
Design Notations
2. Receive breadth from user
3. Set area to length * breadth
4. Display area
Data Types
A named storage location in memory holding a value that can change while the program runs.
AssignmentGiving a variable a value using the = symbol.
| Type | Description | Example |
|---|---|---|
| Integer | Whole number | 10, -5 |
| Real (Float) | Decimal number | 3.14, 0.5 |
| String | Text characters | "Hello" |
| Char | Single character | 'A', '!' |
| Boolean | True or False | True |
Storing multiple items under one name.
print(scores[0]) # Prints 10
2. Implementation (Python)
Maths & Logic
Comparisons return a Boolean value: True or False.
| Op | Meaning | Example (x=5) |
|---|---|---|
| and | Both must be True | x>0 and x<10 (True) |
| or | One must be True | x==5 or x==0 (True) |
| not | Reverses True/False | not(x==5) (False) |
# Use str() to join numbers
print("Age: " + str(age))
Constructs
print("Game Over")
print("Adult")
else:
print("Child")
print("Hot")
elif temp > 15:
print("Warm")
else: # Catch-all (Required)
print("Cold")
Used when you know how many times to loop.
print(i)
Loops until a condition is met.
password = input(...)
Pre-defined Functions
| Function | Purpose |
|---|---|
| input() | Get text from user |
| print() | Display text |
| int() | Convert to Integer |
| float() | Convert to Real |
| str() | Convert to String |
| len() | Length of string/list |
| round(x, 2) | Round to 2 decimal places |
| random.randint() |
Generate random number Requires: import random |
3. Standard Algorithms (Core)
Input Validation
while score < 0 or score > 100:
print("Error!")
score = int(input("Try again: "))
while len(pw) < 8:
print("Too short!")
pw = input("Try again: ")
while opt not in ["A", "B", "C"]:
print("Invalid!")
opt = input("A, B or C: ").upper()
Running Total
Adds up a series of numbers. Uses a Fixed Loop.
- Set total to 0.
- Loop X times.
- Get number.
- Add number to total.
- Display total (after loop).
for i in range(5):
num = int(input("Number? "))
total = total + num
print("Final Total:", total)
Traversing Array
Visiting every item in a list (e.g., for Linear Search or Counting).
- Set up list.
- Loop through list items.
- Check/Process current item.
target = "Bob"
found = False
for person in names:
if person == target:
found = True
print("Found him!")
4. Testing & Evaluation
Test Data
Example: A program accepts numbers 1 to 100.
e.g., 5, 20, 50, 99
e.g., 1 and 100
e.g., 0, 101, -5, "Ten"
Error Types
Grammar mistakes. The code won't even start.
print("Hello" <- Missing )
if x = 10: <- Need ==
Crashes *while* running (Runtime error).
num = 5 / 0 <- Impossible
print(score) <- Not created yet
Runs without crashing, but gives the wrong result.
area = length + breadth
avg = a + b / 2 <- BODMAS!
Evaluation
Checking the quality of the final solution.
-
Fitness for Purpose
Does it meet the functional requirements?
e.g. Program successfully calculates the average mark. -
Robustness
Can it cope with errors without crashing?
e.g. Using a While loop to validate input range. -
Readability
Is it easy for a human to read?
e.g. Using meaningful variable names (total_score) and internal comments (# calc avg). -
Efficiency
Does it use resources (CPU/RAM) well?
e.g. Using a Loop instead of writing the same code 5 times.
5. Worked Example: Analysis & Design
1. Analysis
A program is needed to store 5 marks for a student, calculate the average, and determine if they pass.
- Input: Student Name, 5 Marks (0-100).
- Process: Calculate total, Calculate average, Determine Pass/Fail (>=50).
- Output: Name, Average, Pass/Fail message.
- The program must be easy to read.
- It must validate inputs to ensure no invalid marks (e.g., -5 or 150) crash the system.
2. Design (Pseudocode)
2. RECEIVE student_name FROM KEYBOARD
3. FOR loop FROM 1 TO 5
4. RECEIVE mark FROM KEYBOARD
5. WHILE mark < 0 OR mark > 100
6. DISPLAY "Invalid Mark"
7. RECEIVE mark FROM KEYBOARD
8. END WHILE
9. ADD mark TO total
10. END FOR
11. SET average TO total / 5
12. DISPLAY student_name AND average
13. IF average >= 50 THEN
14. DISPLAY "PASS"
15. ELSE
16. DISPLAY "FAIL"
17. END IF
3. User Interface
Visualising the input/output flow.
Enter mark 1: 45
Enter mark 2: 105
Invalid! Range is 0-100.
Try again: 95
...
--- Results for Alice ---
Average Mark: 72.0
Result: PASS
6. Worked Example: Implementation & Evaluation
4. Implementation (Code)
total = 0
# Get Input
student_name = input("Enter student name: ")
# Loop for 5 marks
for i in range(5):
score = int(input("Enter mark: "))
# Validation using Logical OR
while score < 0 or score > 100:
print("Invalid! Range is 0-100.")
score = int(input("Try again: "))
# Running Total
total = total + score
# Process Average
average = total / 5
average = round(average, 2)
# Output & Decision using Logical AND
print("--- Results for " + student_name + " ---")
print("Average Mark: " + str(average))
if average >= 70:
print("Result: DISTINCTION")
elif average >= 50 and average < 70:
print("Result: PASS")
else:
print("Result: FAIL")
5. Testing
| Type | Input | Expected |
|---|---|---|
| Normal | 50 | Accepted |
| Extreme | 0, 100 | Accepted |
| Exceptional | -1, 101 | Error Msg |
6. Evaluation
Does it meet the Functional Requirements?
Yes, it successfully calculates the average and outputs Pass/Fail correctly.
Can it handle errors/invalid data?
Yes, the while loop catches marks <0 or >100 so the program doesn't crash or give bad results.
Is the code easy for a human to understand?
Yes, uses meaningful names (e.g., student_name, total) and internal comments (# Calculate Average).
Does it use resources well?
Yes, using a For Loop reduces lines of code (vs writing input code 5 times). Using an Array is better than 5 separate variables.