What's the golden code/comment ratio? [closed]

2020-02-26 03:40发布

Is there a code/comment ratio that you consider to be a sign of good (bad) code health?

Can you give examples of open source projects that are considered to be well coded and their respective comment ratio?

(I realize that no ratio is "true" for every project and there may very well be crappy projects that exhibit this theoretical golden ratio. Still...)

26条回答
啃猪蹄的小仙女
2楼-- · 2020-02-26 04:29

I try to keep comments at a minimum. Code should be self explainetory and while source code tends to change the comments almost always remain behind as a wrong explaination.

查看更多
ゆ 、 Hurt°
3楼-- · 2020-02-26 04:30

There is no such thing as a good comment to code ratio. In the old days some people believed that you needed to have a comment at the head of every function explaining what it does.

However, with the advent of modern languages code is pretty much self documenting. This means that the only reasons left to put a comment in the code is to either explain where an oddball decision came from or to help with understanding a really complicated subject.

查看更多
登录 后发表回答