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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Self Documenting Code Is Bullshit

13 点作者 klausbreyer11 个月前

5 条评论

skyzyx10 个月前
I used to own an API service at work, where we worked hard to ensure that the documentation was of a very high quality. When I got promoted and moved to a new team, I&#x27;d warned my manager NOT to hand it over to one team that was remarkably bad at their work. My manager did anyway.<p>During the transition, the new development lead said &quot;I&#x27;m not going to read the documentation. If the code isn&#x27;t self-documenting, we&#x27;re going to rewrite it.&quot; Note that he said that not knowing anything about the service they were taking over. Also, it was in a language that had never established strong patterns for itself, so self-documenting when there are no strong patterns is generally meaningless.<p>Over the next 6 months, he proceeded to ruin the service to the point where it was impacting customers, and got fired for it. In any project of large enough size, self-documenting code falls apart unless you are <i>remarkably</i> good at it. IMO, Go&#x27;s standard library is an exception to my experience.
ibash11 个月前
&gt; If users have to read a method’s code before they can use it, that’s not an abstraction! Good abstractions must be documented outside the actual code, or they do not abstract anything at all.<p>That’s not true at all. Good abstractions are methods or classes you can forget the details of and still use effectively. It doesn’t mean you shouldn’t understand them at some point.
tracker111 个月前
It seems that JSDoc generated documents are an example of close to just this... you don&#x27;t reference the code, you reference the docs. But the docs live inside the code for generation.<p>If you otherwise have separate documentation that is not generated, if the system&#x2F;library has any complexity there&#x27;s a greater chance that documentation doesn&#x27;t align with implementation and bugs will creep in. That&#x27;s not to mention stupid developer decisions, such as weird date normalization&#x2F;structure or similar usage of magic numbers over text keys&#x2F;flags.
mewpmewp211 个月前
It would be good to see some code samples with documentation for argument&#x27;s sake, because the first thought is that you would be pretty much just duplicating pseudocode type of thing.
alanwreath11 个月前
and code comments are eventually just lies...