What is self-documenting code and can it replace well documented code? [closed]

问题:

As it currently stands, this question is not a good fit for our Q&A format. 就目前而言,这个问题不适合我们的问答形式。 We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. 我们希望答案得到事实、参考或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。 If you feel that this question can be improved and possibly reopened, visit the help center for guidance. 如果您认为此问题可以改进并可能重新打开,请访问帮助中心以获取指导。
Closed 9 years ago . 9年前关闭。

I have a colleague who insists that his code doesn't need comments, it's "self documenting."我有一位同事坚持认为他的代码不需要注释,它是“自我记录”。

I've reviewed his code, and while it's clearer than code which I've seen others produce, I still disagree that self-documenting code is as complete and useful as well commented and documented code.我查看了他的代码,虽然它比我见过的其他人编写的代码更清晰,但我仍然不同意自文档化代码与注释和文档化代码一样完整和有用。

Help me understand his point of view.帮助我理解的观点。

  • What is self documenting code什么是自记录代码
  • Can it really replace well commented and documented code它真的可以取代注释良好和文档化的代码吗
  • Are there situations where it's better than well documented and commented code是否存在比有据可查和注释的代码更好的情况
  • Are there examples where code cannot possibly be self-documenting without comments是否有代码在没有注释的情况下不可能自我记录的示例

Maybe it's just my own limitations, but I don't see how it can be a good practice.也许这只是我自己的局限性,但我不明白它如何成为一种好的做法。

This is not meant to be an argument - please don't bring up reasons why well commented and documented code is high priority - there are many resources showing this, but they aren't convincing to my peer.这并不意味着要成为一个论点 - 请不要提出为什么注释良好和文档化的代码是高优先级的原因 - 有很多资源表明了这一点,但它们并不能让我的同行信服。 I believe I need to more fully understand his perspective to convince him otherwise.我相信我需要更充分地理解他的观点才能说服他。 Start a new question if you must, but don't argue here.如果必须的话,开始一个新问题,但不要在这里争论。

Wow, quick response!哇,反应快! Please read all the existing answers and provide comments to answers rather than add new answers, unless your answer really is substantially different from every other answer in here.请阅读所有现有答案并对答案提供评论,而不是添加新答案,除非您的答案确实与此处的所有其他答案大不相同。

Also, those of you who are arguing against self documenting code -this is primarily to help me understand the perspective (ie, positive aspects) of self-documenting code evangelists.另外,那些反对自我记录代码的人 - 这主要是为了帮助我理解自我记录代码传播者的观点(即积极方面)。 I expect others will downvote you if you don't stay on topic.我希望如果你不关注话题,其他人会贬低你。


解决方案:

参考一: https://en.stackoom.com/question/sND
参考二: https://stackoom.com/question/sND
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章