知识卡片
意图命名不能替代必要解释
把条件提取成有意义函数可减少逐行复述注释,仍应保留设计原因、外部约束和异常行为说明。解释性注释可能陈旧,需要随行为维护;“有注释就是坏味道”不是绝对规则。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
- · 重构与技术债
原书出处 · 1 处
- · 查看原书依据
Comments can grow stale and they can lie. Comments can make code even harder to understand when there’s too many of them. We can avoid these problems by using sensible variable names, proper abstraction of our code into functions with single responsibility, and unit tests, as illustrated in the following examples. Bad example: # Check to see if employee is eligible for full benefits if
参考来源
- 位置:《Effective Machine Learning Teams (David Tan, Ada Leung, David Colls)》第08章《重构与技术债》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Effective Machine Learning Teams (David Tan, Ada Leung, David Colls)/_epub-src/OEBPS/ch08.html)
- 结论依据:摘录中关于意图命名不能替代必要解释的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。
- 原始内容:Comments can grow stale and they can lie. Comments can make code even harder to understand when there’s too many of them. We can avoid these problems by using sensible variable names, proper abstraction of our code into functions with single responsibility, and unit tests, as illustrated in the following examples. Bad example: # Check to see if employee is eligible for full benefits if