Structure Diagrams
1. Top-Down Design
Top-Down Design is the process of breaking a main problem into smaller parts (sub-problems) until each part is simple enough to be solved. A Structure Diagram is the visual tool used to show this hierarchy.
2. Example: Smart Alarm Clock System
Notice how the main system is decomposed into three main modules, which are then broken down further.
Smart Alarm Clock
Set Alarm
Input Time
Check Time
Compare to Current
Trigger Alarm
Sound Buzzer
3. Key Rules for Structure Diagrams
- Hierarchy: The "Parent" module is at the top; "Children" modules are below.
- No Logic: Unlike flowcharts, structure diagrams do not show decisions (IF) or loops (WHILE). They only show the components of the system.
- Modularization: Each box represents a discrete task that could be written as a separate subroutine (function/procedure).
4. Advantages of Modular Design
Easier Debugging: It is easier to find and fix an error in a small module of 10 lines than in a program of 1,000 lines.
Collaboration: Different programmers can work on different modules at the same time.
Reusability: Once a module is written (e.g., a "Calculate Tax" module), it can be used in other programs.
Maintenance: Modules can be updated or replaced individually without breaking the entire system.
⚠️ Exam Tip: If an exam asks you to "Complete a structure diagram," remember to check the levels. Ensure the new module you add is a sub-task of the module directly above it.