Session 16
Structured Programming Review
This session is about reviewing code against structured programming principles. The goal is to identify confusing control flow or poor structure and rewrite the code using clear sequence, selection, iteration, and functions.
Problem Statement
Select a small portion of any program written by you. Check if the selected portion has constructs that violate the structured programming paradigm. If yes, rewrite the code to conform to structured programming. If no, check another portion of code.
Expected Deliverable
Submit the original code, review observations, rewritten structured version, and justification.
Structured Programming Principles
- Use sequence, selection, and iteration.
- Avoid unnecessary
goto. - Keep functions focused.
- Avoid deeply tangled control flow.
- Use meaningful function boundaries.
Review Checklist
| Check | Question |
|---|---|
| Flow | Is control flow clear? |
| Functions | Can repeated logic be extracted? |
| Branching | Are conditions readable? |
| Loops | Are loop boundaries clear? |
| Data | Are variables scoped properly? |
Submission Checklist
- Include original code.
- Mark violations.
- Include rewritten code.
- Explain how the rewrite improves structure.