什么是黄金代码/评论比率? [英] What's the golden code/comment ratio?

查看:153
本文介绍了什么是黄金代码/评论比率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您是否认为代码/评论比例是良好(不良)代码健康状况的标志?

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

推荐答案

注释应该非常罕见和有价值,几乎总是表达为什么从不是如何(例外是当如何是复杂的,不容易从代码中辨别)。

Comments should be very rare and valuable, almost always expressing the "why" and never the "how" (the exception being when the how is complex and not easily discernible from the code).

每个注释是一个提示,你可能需要重构使代码的意图更清晰。

Every comment is a hint that you may need to refactor to make the code's intent clearer. Every comment risks becoming out of date as soon as it's written.

除了我们的 xUnit.net project ,但有些人似乎发现代码清晰易读。 :)

We have almost no comments aside from XML comments in our xUnit.net project, but some people seem to find the code clear and easy to read. :)

这篇关于什么是黄金代码/评论比率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆