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

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

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

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


当前回答

尽管我完全支持测试驱动开发(TDD),但我认为在开发人员开始对问题的解决方案进行原型化的整个开发周期之前,还有一个至关重要的步骤。

我们经常陷入试图遵循我们的TDD实践来寻找一个可能被误导的解决方案,因为我们对这个领域不够了解。简单的原型通常可以阐明这些问题。

原型是很好的,因为与首先编写测试相比(有时),您可以快速地浏览和丢弃更多的代码。然后,您可以开始开发过程,在空白的石板,但更好的理解。

其他回答

源文件太20世纪了。

在函数/方法的主体中,将过程逻辑表示为线性文本是有意义的。即使逻辑不是严格的线性,我们也有良好的编程结构(循环、if语句等),允许我们使用线性文本清晰地表示非线性操作。

But there is no reason that I should be required to divide my classes among distinct files or sort my functions/methods/fields/properties/etc in a particular order within those files. Why can't we just throw all those things within a big database file and let the IDE take care of sorting everything dynamically? If I want to sort my members by name then I'll click the member header on the members table. If I want to sort them by accessibility then I'll click the accessibility header. If I want to view my classes as an inheritence tree, then I'll click the button to do that.

Perhaps classes and members could be viewed spatially, as if they were some sort of entities within a virtual world. If the programmer desired, the IDE could automatically position classes & members that use each other near each other so that they're easy to find. Imaging being able to zoom in and out of this virtual world. Zoom all the way out and you can namespace galaxies with little class planets in them. Zoom in to a namespace and you can see class planets with method continents and islands and inner classes as orbitting moons. Zoom in to a method, and you see... the source code for that method.

基本上,我的观点是,在现代语言中,不管你把你的类放在什么文件中,或者你定义一个类的成员的顺序是什么,那么为什么我们仍然被迫使用这些古老的实践呢?还记得Gmail出来谷歌说的是"搜索,不排序"吗?那么,为什么同样的哲学不能应用于编程语言呢?

“程序员是天生的,不是后天培养的。”

将XML存储在关系数据库中的CLOB中通常是一种可怕的逃避。它不仅在性能方面很糟糕,还将正确管理数据结构的责任从数据库架构师转移到应用程序程序员身上。

代码即设计:Jack W. Reeves的三篇文章

任何软件的源代码都是其最准确的设计文档。其他的一切(规格,文档,有时还有注释)要么是不正确的,过时的,要么是误导性的。

肯定会让你在任何地方被炒。

代码就是设计