Problems in Procedure-Oriented Approach
1. What POP Means (beginner)
Procedure-Oriented (POP) = C-style: program = functions + global data. Data open to all (no protection!), code copied everywhere. Works for 100 lines, collapses at 10,000!
2. Problems Table (exam list — 5!)
| Problem | Plain meaning | Example pain |
|---|---|---|
| No data hiding | globals editable by anyone | balance changed by any function (fraud!) |
| No reuse | copy-paste code | 5 sorting copies (fix bug 5×!) |
| Hard maintenance | one change breaks many | change struct → edit 20 functions! |
| No real-world mapping | functions, not objects | bank as functions, not Account objects |
| No extensibility | new feature = rewrite | add SavingsAccount → touch everything! |
3. Code Smell (C-style global!)
// POP pain (C):
float balance; // GLOBAL (anyone edits!)
void withdraw(float x) { balance -= x; } // no guard!
void hack() { balance = 999999; } // oops — direct access!
Java fixes: private balance + withdraw() method guard (next topic!).
4. Why OOP Wins (bridge!)
Encapsulation (lock data), Inheritance (reuse), Polymorphism (extend) — each POP problem has an OOP cure.
5. Exam Points
- List 4-5 POP problems with example — 5 marks, very frequent.
- Global-data + reuse pain — 3 marks, most-asked rows.