Clarify benefits of factory methods in Module 2
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 半天
- 新手友好度
- 55/100
- Issue 类型
- 文档
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- jupyter-notebook, python
调研方向
从 Module 2 中的 static methods 部分开始,审查其中对 factory methods 的现有说明。添加所要求的术语、理由以及 datetime 和 polars 示例;完成的标准是该部分说明何时以及为何使用此模式,并包含列出的示例。
由索引模型根据 Issue 内容生成。
描述
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
-
Name the pattern - Use the term "factory method" or "alternative constructor" so students can recognize and search for it
-
Explain the "why" - Python doesn't support multiple
__init__signatures, so factory methods provide multiple construction paths with semantic clarity -
Add stdlib examples from datetime:
datetime.fromtimestamp()datetime.fromisoformat()date.fromordinal()
-
Add examples from polars:
pl.read_csv(),pl.read_parquet(),pl.read_json()(module-level factories)DataFrame.to_dict()→pl.from_dict()round-trippl.from_numpy(),pl.from_pandas()
These examples show the pattern is pervasive in well-designed Python APIs.
- 主要语言
- Jupyter Notebook
- 星标
- 8
- 派生
- 1
- 平均合并
- 4 分钟
- 30 天内合并 PR
- 1
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
DHI/python-package-development 的其他 Issue
-
难度 2/5 1-2 天 新手友好度 88/100
-
难度 2/5 1-2 天 新手友好度 72/100
DHI/python-package-development#37 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 48/100
-
难度 2/5 1-3 小时 新手友好度 48/100
查看 DHI/python-package-development 的全部 Issue
相似的 Issue
-
sync-en
难度 1/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 78/100
agilepathway/label-checker#640 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
BasedHardware/omi#15662 · 1 条评论 ·
-
documentation help wanted
难度 2/5 1-3 小时 新手友好度 90/100
-
难度 1/5 1-3 小时 新手友好度 88/100