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

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

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

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


当前回答

依赖管理软件弊大于利

我在Java项目中工作过,其中包括超过100个不同的库。在大多数情况下,每个库都有自己的依赖项,而这些依赖库也有自己的依赖项。

像Maven或Ivy这样的软件应该通过自动获取每个库的正确版本,然后递归获取其所有依赖项来“管理”这个问题。

问题解决了,对吧?

错了。

下载库是依赖项管理的简单部分。困难的部分是创建软件的心理模型,以及它如何与所有这些库交互。

我不受欢迎的观点是:

如果你不能口头解释,在你的头脑中,你的项目中所有库之间的基本交互,你应该消除依赖直到你可以。

同样地,如果列出从某个函数直接或间接调用的所有库(及其方法)所用的时间超过10秒,那么您在管理依赖关系方面做得很差。

您应该能够轻松回答“我的应用程序的哪些部分实际上依赖于库XYZ?”

当前的依赖关系管理工具弊大于利,因为它们很容易创建极其复杂的依赖关系图,而且它们实际上没有提供减少依赖关系或识别问题的功能。

我见过开发人员包含了10或20 MB的库,在项目中引入了数千个依赖类,只是为了消除几十行简单的自定义代码。

使用库和框架是很好的。但成本总是存在的,掩盖成本的工具本身就是有问题的。

此外,有时(注意:当然不总是)通过编写一些小的类来实现您所需要的东西比引入对大型通用库的依赖更好。

其他回答

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).

应该禁止调试器。这将迫使人们编写可通过单元测试测试的代码,最终将导致更好的代码质量。

从所有编程ide中删除复制和粘贴。复制和粘贴代码是非常糟糕的,这个选项应该完全删除。然后程序员可能会懒得重新输入所有的代码,所以他会创建一个函数并重用代码。

无论何时使用单例,都要给自己一个耳光。单例几乎从来没有必要,大多数时候只是全局变量的花哨名称。

让您的业务逻辑远离DB。或者至少,保持它非常精简。让DB做它应该做的事情。让代码做它应该做的事情。时期。

If you're a one man show (basically, arrogant & egotistical, not listening to the wisdom of others just because you're in control), do as you wish. I don't believe you're that way since you're asking to begin with. But I've met a few when it comes to this subject and felt the need to specify. If you work with DBA's but do your own DB work, keep clearly defined partitions between your business objects, the gateway between them and the DB, and the DB itself. If you work with DBA's and aren't allowed to do your DB work (either by policy or because they're premadonnas), you're very close to being a fool placing your reliance on them to get anything done by putting code-dependant business logic in your DB entities (sprocs, functions, etc.). If you're a DBA, make developers keep their DB entities clean & lean.

我的观点是,有太多的人在做编程决策时不应该担心实现。

汇编语言是最好的编程语言。