Cnfzh 软件博客

读《代码整洁之道》的十三条批注

十年后再读,批注比正文还多。

命名

变量名长短应与作用域大小成正比。d 这种名字只配出现在三行之内的循环里。

函数

一个函数只做一件事的标准,是「能否再拆出一个名字」。

注释

好的注释解释「为什么」,而不是复述「做了什么」。后者是代码没写清楚的证据。

评论 0

还没有评论,来说两句吧。

提交前需验证邮箱,验证码 10 分钟内有效。

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.