Stage: Intermediate | Prerequisite: All of weeks 1~9
Learning Goals
- Complete a mini project using all OOP, exceptions, and file I/O
- Apply module separation and package structure
1. Considerations When Designing the Project
- Data Model — Which classes will represent it?
- Persistent Storage — JSON? CSV? In what format?
- User Interface — Command-based? Menu-based?
- Module Separation —
models.py,storage.py,cli.py, etc.
2. Recommended Package Structure
my_app/
├── __init__.py
├── models.py # Class definitions (Word, Book, etc.)
├── storage.py # JSON Save/Load
├── cli.py # Main loop, command handling
└── main.py # Entry point
3. Skeleton Example — Flashcard App
Refer to examples/wordbook_skeleton/.
Key Examples (examples/)
| File | Content |
|---|---|
wordbook_skeleton/models.py |
Word, WordBook classes |
wordbook_skeleton/main.py |
Entry point |
⚠️ Common Mistakes
- All code in a single file
main.py— Without separation, if it exceeds 200 lines it becomes a maze - Objects that can't be JSON serialized — Use
dataclass+asdict() - Incorrect timing of saving — Save on every change vs on exit — Decide policy
- Exceptions too narrowly or too broadly used — Only use except where recovery is possible
❓ FAQ
Q1. Can we use dataclass? A. Recommended. Simple data classes are convenient with dataclass. (Explained in detail in Advanced Week 1)
Q2. Single file vs package? A. Single file only if under 50 lines. If more than that, separate.
📝 Final Assignment (exercises/)
Select 1 out of the following 4 options.
exercise1.md— Vocabulary App (CRUD + JSON + Quiz Mode)exercise2.md— Simple Household Ledger (Income/Expenditure + JSON + Category)exercise3.md— Log Analyzer (Split with Regular Expressions + CSV Report)exercise4.md— Contact Manager (OOP) (Contact, AddressBook classes)
Submission
- Modular package structure
- Exception handling, user-friendly messages
- README.md (How to run, How to use)