TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: What's the most annoying part about writing code comments?

3 点作者 Nevin1901大约 3 年前
Working on a project and wondering what you guys think. Feel free to leave your opinion below.

2 条评论

davismwfl大约 3 年前
The most annoying part is the people who don&#x27;t write comments.<p>Code comments are important (sometimes more important than the code), even for code that seems self describing, as in many cases putting a few notes of the &quot;why&quot; is super critical to prevent people from making breaking changes later. That said, I am not advocating for commenting completely self describing code lines, e.g. &#x2F;&#x2F; for loop etc.<p>My personal work style is I first write comments as the outline of what I want to have happen then fill in the details via code. At the end, I&#x27;ll remove the unnecessary comments, but by doing this it helps me make sure my code is fully commented and helps me organize my thoughts before just writing code. The worst case is I sometimes leave unnecessary comments but that&#x27;s fairly minor IMO. This method works at any level of code too, e.g. modules, interfaces, files, functions etc<p>Frankly commenting this way has saved me countless hours of debugging, especially in more complex and code dense functions, algorithms is a good example. Non trivial lambdas is another good example where a good comment can save a ton of time.<p>I also require function header comments with parameter descriptions and return value details etc. Tools like doxygen are invaluable when you work with teams that need to share details on interfaces etc.
评论 #30657790 未加载
WheelsAtLarge大约 3 年前
keeping them up to date. A never ending battle that can&#x27;t be won.