Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Add Ousterhout's comment philosophy to course content

未关闭
#34 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
48/100
Issue 类型
文档
描述清晰度
基本清楚
活跃度
停滞
技术栈
python

调研方向

首先找到 Module 2 和 Module 6 的课程内容,然后查看现有课程如何介绍函数、模块、注释和文档。完成的标准是:课程解释列出的注释原则,包含所提供的对比示例或等效示例,并在适当的情况下添加简短的 Module 6 callback。

由索引模型根据 Issue 内容生成。

描述

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

# 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.

主要语言
Jupyter Notebook
星标
8
派生
1
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

DHI/python-package-development 的其他 Issue

查看 DHI/python-package-development 的全部 Issue

相似的 Issue

更多 Content Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。