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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章