Level 3 / Project 10 - Dependency Boundary Lab¶
Home: README
Learn Your Way¶
| Read | Build | Watch | Test | Review | Visualize | Try |
|---|---|---|---|---|---|---|
| — | This project | — | — | Flashcards | — | Browser |
Estimated time: 50 minutes
Focus¶
- separate io from business logic
Why this project exists¶
This project gives you level-appropriate practice in a realistic operations context. Goal: run the baseline, alter behavior, break one assumption, recover safely, and explain the fix.
Run (copy/paste)¶
Use <repo-root> as the folder containing this repository's README.md.
cd <repo-root>/projects/level-3/10-dependency-boundary-lab
python project.py records.json output.json --config config.json
pytest -q
Expected terminal output¶
Expected artifacts¶
- Processed JSON output file
- Passing tests
- Updated
notes.md
Checkpoint: Baseline code runs and all tests pass. Commit your work before continuing.
Alter it (required) — Extension¶
- Add a
sort_byconfig option to sort output records by a field. - Add a
CsvFileReaderthat reads CSV instead of JSON. - Add a
--dry-runflag that shows what would be processed without writing.
Break it (required) — Core¶
- Pass a config with a rename map that creates duplicate keys — what happens?
- Pass a JSON file that contains a string instead of an array — what error appears?
- Use
InMemoryReaderwith no records — does the pipeline handle empty input?
Fix it (required) — Core¶
- Validate config keys before running the pipeline.
- Handle non-list JSON input by wrapping in a list.
- Add clear error messages when reader/writer operations fail.
Checkpoint: All modifications done, tests still pass. Good time to review your changes.
Explain it (teach-back)¶
- What is "dependency inversion" and why does it make code testable?
- How do
InMemoryReader/InMemoryWriterreplace real files in tests? - Why is the
run()orchestrator the ONLY place that touches I/O? - What is a Python
Protocoland how does it define an interface?
Mastery check¶
You can move on when you can: - separate I/O from business logic, - test business logic without touching the filesystem, - use the Protocol pattern for dependency boundaries, - build a configurable data processing pipeline.
Related Concepts¶
- Errors and Debugging
- Files and Paths
- How Imports Work
- Virtual Environments
- Quiz: Errors and Debugging
| ← Prev | Home | Next → |
|---|---|---|