这绝对是主观的,但我想尽量避免它变成争论。我认为如果人们恰当地对待它,这将是一个有趣的问题。

这个问题的想法来自于我对“你最讨厌的语言的哪五件事?”问题的回答。我认为c#中的类在默认情况下应该是密封的——我不会把我的理由放在这个问题上,但我可能会写一个更完整的解释来回答这个问题。我对评论中的讨论热度感到惊讶(目前有25条评论)。

那么,你有什么有争议的观点?我宁愿避免那些基于相对较少的基础而导致相当宗教的事情(例如,大括号放置),但例如可能包括“单元测试实际上并没有多大帮助”或“公共字段确实是可以的”之类的事情。重要的是(至少对我来说)你的观点背后是有理由的。

请提出你的观点和理由——我鼓励人们投票给那些有充分论证和有趣的观点,不管你是否恰好同意这些观点。


当前回答

我有争议的观点是John Carmack(游戏邦注:代表作有ID Software, Quake等)并不是一个优秀的程序员。

不要误解我的意思,在我看来他是一个非常聪明的程序员,但当我注意到quake源代码中的“#define private public”这一行后,我不禁认为他是一个无论如何都能完成工作的人,但在我的定义中,他不是一个好程序员:) 这个观点让我陷入了很多激烈的讨论;)

其他回答

如果你有合适的工具,并花时间正确地编写,那么软件就可以没有错误。

Never make up your mind on an issue before thoroughly considering said issue. No programming standard EVER justifies approaching an issue in a poor manner. If the standard demands a class to be written, but after careful thought, you deem a static method to be more appropriate, always go with the static method. Your own discretion is always better than even the best forward thinking of whoever wrote the standard. Standards are great if you're working in a team, but rules are meant to be broken (in good taste, of course).

生成的文档几乎总是毫无价值的。

或者,作为一个推论:您的API需要为维护者和用户提供单独的文档集。

实际上有两类人需要了解您的API:维护者,他们必须了解您的实现的细节,以便有效地完成工作;用户,他们需要高级的概述、示例和关于他们所访问的每个方法的效果的详细细节。

我从未遇到过在这两个方面都成功的生成文档。通常,当程序员为工具编写注释以提取和生成文档时,他们的目标是介于两者之间的某个地方——刚刚足够的实现细节让用户感到厌烦和困惑,但不足以显著帮助维护者,并且没有足够的概述对用户有任何真正的帮助。

As a maintainer, I'd always rather have clean, clear comments, unmuddled by whatever strange markup your auto-doc tool requires, that tell me why you wrote that weird switch statement the way you did, or what bug this seemingly-redundant parameter check fixes, or whatever else I need to know to actually keep the code clean and bug-free as I work on it. I want this information right there in the code, adjacent to the code it's about, so I don't have to hunt down your website to find it in a state that lends itself to being read.

As a user, I'd always rather have a thorough, well-organized document (a set of web pages would be ideal, but I'd settle for a well-structured text file, too) telling me how your API is architectured, what methods do what, and how I can accomplish what I want to use your API to do. I don't want to see internally what classes you wrote to allow me to do work, or files they're in for that matter. And I certainly don't want to have to download your source so I can figure out exactly what's going on behind the curtain. If your documentation were good enough, I wouldn't have to.

无论如何,这就是我的看法。

一个文件一个类

谁在乎呢?我更喜欢把整个程序包含在一个文件中,而不是一百万个不同的文件。

在1970年1月1日之前,真和假是相反的……