Topic 3.2 — Impact of Program Design
Goal: explain how good (or bad) program design affects readability, correctness, testing, and reuse. Learn why designing with classes/methods matters before writing lots of code.
The big idea
Program design isn’t “extra”—it changes how easy it is to build and maintain a program. Good design makes code easier to understand, easier to test, and less likely to break.
Good design usually means…
- Methods do one job (clear purpose)
- Names explain intent (not just “x” and “doStuff”)
- Code is not repeated (reuse helper methods)
- Data + behavior are grouped logically (classes)
Why it matters: four big impacts
| Impact | Good design helps because… | Bad design causes… |
|---|---|---|
| Readability | someone can quickly see what the code does | confusing code that’s hard to follow |
| Correctness | smaller parts are easier to reason about | bugs hide inside giant blocks of code |
| Testing | you can test methods one at a time | hard to test without running everything |
| Reuse | helper methods can be used again | copy/paste code (more bugs, more edits) |
Example: duplicated code (bad)
Copy/paste works… until you need to change it.
// Same logic repeated in multiple places
if (score >= 90) { grade = "A"; }
else if (score >= 80) { grade = "B"; }
// ... repeated again elsewhere ...
Example: helper method (better)
Put the logic in one place. Reuse it.
public static String letterGrade(int score) {
if (score >= 90) return "A";
if (score >= 80) return "B";
if (score >= 70) return "C";
if (score >= 60) return "D";
return "F";
}
Now if you change grading rules, you update one method.
“Too big” methods are a red flag
- If a method is doing many jobs, it becomes hard to debug.
- Long methods make it easy to miss edge cases.
- Breaking into smaller methods makes the logic clearer.
Design checklist (fast)
- Can I describe this method’s job in 1 sentence?
- Does the name match what it does?
- Am I repeating code anywhere?
- Could this be reused later?
- Is the logic easier as multiple smaller methods?
Quick self-check
- How does good design help testing?
- Why does copy/paste code increase bugs?
- What’s a sign a method is “too big”?
- How do helper methods improve maintainability?
- What’s one improvement you’d make to messy code?