Step-wise Refinement
1. The Top-Down Approach
Step-wise refinement is a top-down design strategy. You start with the "Top-Level" goal and continuously decompose it into smaller modules. This continues until each module performs exactly one specific task.
2. Visualizing Refinement: Library System
Manage Library
Add New Book
Lend Book
Return Book
Check Student ID
Update Database
3. The Refinement Process
Consider the task of "Updating a Student's Grade" in your e-consult.co.ke platform:
STEP 1: Update Grade
STEP 1.1: Find Student Record
STEP 1.2: Enter New Grade
STEP 1.3: Save Changes
// Refining Step 1.1 further...
STEP 1.1.1: Input Student ID
STEP 1.1.2: Search Array/Database for ID
STEP 1.1.3: IF Not Found, Output Error
STEP 1.1: Find Student Record
STEP 1.2: Enter New Grade
STEP 1.3: Save Changes
// Refining Step 1.1 further...
STEP 1.1.1: Input Student ID
STEP 1.1.2: Search Array/Database for ID
STEP 1.1.3: IF Not Found, Output Error
4. Benefits of this Method
- Complexity Management: Prevents the programmer from being overwhelmed by a large project.
- Parallel Development: Different programmers can work on different sub-modules (e.g., one works on 1.1, another on 1.2).
- Easier Debugging: Errors can be traced back to a specific, small module rather than a giant program.
⚠️ Exam Note: Structure Charts
In Paper 2, you are often asked to complete a Structure Chart. Remember that arrows showing data moving into a module are parameters, and arrows showing data moving out are return values.