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

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

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

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


当前回答

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

... 那就是当我们(希望)得到它们的时候。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).

其他回答

UML图被高度高估了

当然有一些有用的图,例如复合模式的类图,但是许多UML图是绝对没有价值的。

应该始终使用基于1的数组,而不是基于0的数组。基于0的数组是不自然的、不必要的,而且容易出错。

当我数苹果、员工或小部件时,我从1开始,而不是0。我也这么教我的孩子。不存在第0个苹果或第0个员工或第0个部件。使用1作为数组的基更直观,也更不容易出错。忘掉加一减一的地狱吧(我们过去常这样称呼它)。基于0的数组是计算机科学发明的一种不自然的结构——它们不能反映现实,而计算机程序应该尽可能地反映现实。

使用存储过程

除非您正在编写由不可重用的SQL查询组成的大型过程函数,否则请将数据库的存储过程移到版本控制中。

观点:永远不要在“调试”和“发布”版本之间有不同的代码

主要原因是发布代码几乎从未经过测试。最好让在测试中运行的代码与在野外运行的代码相同。

如果我有争议的话,我不得不说乔恩·斯基特并不是万能的。