DHI / DHI/python-package-development
Clarify benefits of factory methods in Module 2
- Ngôn ngữ chính
- Jupyter Notebook
- Star
- 8
- Fork
- 1
- Merge trung bình
- 4 phút
- Pull request đã merge (30 ngày)
- 1
Mô tả
The static methods section in Module 2 shows *how* to create factory methods but could better explain *when and why* to use them.
## Current state
The notes mention it's "less cumbersome" to create instances, but the pedagogical value could be stronger.
## Suggested improvements
1. **Name the pattern** - Use the term "factory method" or "alternative constructor" so students can recognize and search for it
2. **Explain the "why"** - Python doesn't support multiple `__init__` signatures, so factory methods provide multiple construction paths with semantic clarity
3. **Add stdlib examples from datetime**:
- `datetime.fromtimestamp()`
- `datetime.fromisoformat()`
- `date.fromordinal()`
4. **Add examples from polars**:
- `pl.read_csv()`, `pl.read_parquet()`, `pl.read_json()` (module-level factories)
- `DataFrame.to_dict()` → `pl.from_dict()` round-trip
- `pl.from_numpy()`, `pl.from_pandas()`
These examples show the pattern is pervasive in well-designed Python APIs.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Start with the static methods section in Module 2 and review its current explanation of factory methods. Add the requested terminology, rationale, and datetime and polars examples; done means the section explains when and why to use the pattern and includes the listed examples.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- jupyter-notebook, python
- Lĩnh vực
- documentation
- Loại issue
- Tài liệu
- Độ khó
- 2/5
- Thời gian dự kiến
- Nửa ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 55/100