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

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

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

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


当前回答

复制/粘贴是万恶之源。

其他回答

打印语句是调试代码的有效方法

我相信用System.out.println(或任何适用于您的语言的打印语句)来调试代码是完全没问题的。通常,这比调试要快,并且可以将打印输出与应用程序的其他运行进行比较。

只要确保在进入生产环境时删除打印语句(或者更好的做法是将它们转换为日志语句)

对于一个优秀的程序员来说,语言不是问题。

这可能不是很有争议,但我听到很多其他程序员的抱怨,比如“为什么他们不都用delphi?”,“c#糟透了”,“如果他们强迫我用java,我就会换公司”等等。 我所认为的是,一个好的程序员是灵活的,能够用他一生中可能不得不学习的任何编程语言编写好的程序

“评论是谎言”

注释不能运行,而且很容易被忽略。最好是用清晰的、由单元测试说明的重构代码来表达意图。(当然是编写TDD的单元测试…)

我们不写注释,因为它们很冗长,而且模糊了代码中真正发生的事情。如果你觉得需要注释——找出代码中不清楚的地方,然后重构/编写更清晰的测试,直到不需要注释……

... 我从极限编程中学到的东西(当然,假设你已经建立了清理代码的团队规范……)

设计模式是石器时代编程语言设计的一个症状

他们有自己的目的。很多优秀的软件都是用它们开发出来的。但事实上,我们需要编写这些心理抽象的“配方”,关于你的代码如何工作/应该如何工作,这说明缺乏足够有表现力的编程语言来为我们处理这种抽象。

补救措施,我认为,在于允许你将越来越多的设计嵌入到代码中的语言,通过定义可能不存在或可能没有普遍适用性,但在你的代码不断处理的情况下真的真的有意义的语言结构。Scheme的人已经知道这一点很多年了,Scheme宏可能会让大多数猴子尿裤子。

关系数据库系统将是自切片面包以来最好的东西……

... 那就是当我们(希望)得到它们的时候。SQL数据库太糟糕了,一点都不好笑。

我觉得有趣的是,认证dba认为SQL数据库系统是关系数据库系统。这说明了上述认证的质量。

困惑吗?读c·j·戴特的书。

edit

为什么叫关系?这个词是什么意思?

如今,拥有强大(哎呀,任何)数学背景的程序员(或认证DBA, wink)是例外,而不是常见情况(我也是常见情况的一个实例)。SQL的表、列和行,以及被称为实体/关系建模的笑话,只是在伤害上加了侮辱。难怪有一种误解,认为关系数据库系统之所以这样叫,是因为实体(表)之间的某些关系(外键?)是如此普遍。

事实上,关系源于关系的数学概念,因此与集合理论和函数密切相关(在数学意义上,而不是任何编程意义上)。

[http://en.wikipedia.org/wiki/Finitary_relation][2]:

In mathematics (more specifically, in set theory and logic), a relation is a property that assigns truth values to combinations (k-tuples) of k individuals. Typically, the property describes a possible connection between the components of a k-tuple. For a given set of k-tuples, a truth value is assigned to each k-tuple according to whether the property does or does not hold. An example of a ternary relation (i.e., between three individuals) is: "X was-introduced-to Y by Z", where (X,Y,Z) is a 3-tuple of persons; for example, "Beatrice Wood was introduced to Henri-Pierre Roché by Marcel Duchamp" is true, while "Karl Marx was introduced to Friedrich Engels by Queen Victoria" is false.

维基百科说得很清楚:在SQL数据库管理系统中,这样的三元关系将是一个“表”,而不是一个“外键”(我冒昧地重命名了关系的“列”:X = who, Y = to, Z = by):

CREATE TABLE introduction (
  who INDIVIDUAL NOT NULL
, to INDIVIDUAL NOT NULL
, by INDIVIDUAL NOT NULL
, PRIMARY KEY (who, to, by)
);

此外,它将包含(可能在其他中)这个“row”:

INSERT INTO introduction (
  who
, to
, by
) VALUES (
  'Beatrice Wood'
, 'Henri-Pierre Roché'
, 'Marcel Duchamp'
);

但不是这个:

INSERT INTO introduction (
  who
, to
, by
) VALUES (
  'Karl Marx'
, 'Friedrich Engels'
, 'Queen Victoria'
);

关系数据库字典:

relation (mathematics) Given sets s1, s2, ..., sn, not necessarily distinct, r is a relation on those sets if and only if it's a set of n-tuples each of which has its first element from s1, its second element from s2, and so on. (Equivalently, r is a subset of the Cartesian product s1 x s2 x ... x sn.) Set si is the ith domain of r (i = 1, ..., n). Note: There are several important logical differences between relations in mathematics and their relational model counterparts. Here are some of them: Mathematical relations have a left-to-right ordering to their attributes. Actually, mathematical relations have, at best, only a very rudimentary concept of attributes anyway. Certainly their attributes aren't named, other than by their ordinal position. As a consequence, mathematical relations don't really have either a heading or a type in the relational model sense. Mathematical relations are usually either binary or, just occasionally, unary. By contrast, relations in the relational model are of degree n, where n can be any nonnegative integer. Relational operators such as JOIN, EXTEND, and the rest were first defined in the context of the relational model specifically; the mathematical theory of relations includes few such operators. And so on (the foregoing isn't meant to be an exhaustive list).