DHI / DHI/python-package-development
Add Ousterhout's comment philosophy to course content
- 主要语言
- Jupyter Notebook
- 星标
- 8
- 派生
- 1
- 平均合并
- 4 分钟
- 30 天内合并 PR
- 1
描述
Consider adding content about code comments based on Ousterhout's "A Philosophy of Software Design".
## Key concepts to cover
- Comments as abstraction (describing *what* and *why*, not *how*)
- High-level vs. implementation comments
- Comments that reveal what code cannot express
- When to improve code clarity instead of adding comments
## Example
```python
# BAD: comment restates what the code does
def get_temperature(measurements):
# Return None if list is empty
if len(measurements) == 0:
return None
# Calculate the average temperature
return sum(measurements) / len(measurements)
# GOOD: comment explains why (the business reason isn't obvious from code)
def get_temperature(measurements):
# Sensors report -999 when disconnected; treat as missing data
valid = [m for m in measurements if m > -900]
if len(valid) == 0:
return None
return sum(valid) / len(valid)
```
The first example's comments add no value—the code is self-explanatory. The second example's comment reveals *why* we filter values below -900, which you cannot understand from the code alone.
## Suggested placement
- **Module 2 (Functions, classes, modules)** - Core principles, taught early when students learn to write functions
- **Module 6 (Documentation)** - Brief callback distinguishing inline comments from API documentation
Module 2 is preferred since teaching good commenting habits early will improve code quality throughout the course.
贡献指南
这个仓库没有索引到贡献指南
调研方向
Start by locating the course content for Module 2 and Module 6, then review how existing lessons present functions, modules, comments, and documentation. Done means the course explains the listed comment principles, includes the provided contrasting examples or equivalent examples, and adds the brief Module 6 callback if appropriate.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- content, documentation
- Issue 类型
- 文档
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100