Block 148: Capstone: Refactoring & Modularization
Restructure your code into clean, reusable modules.
Concepts
- Splitting notebook into .py modules: data_loader.py, model.py, viz.py
- Using functions for every repeated operation
- Adding docstrings to all functions
- Creating a main.py or app.py entry point
Code Examples
See exercise below.
Exercise
Refactor your project: move all functions to at least 2 separate .py files. Ensure your notebook can import and use them. Add docstrings to every function (what it does, args, returns).
Homework
Why is modular code better than a single long notebook? List 4 specific benefits. Friday