将代码合约部署到生产环境中是不是不好?

发布于 2024-10-17 11:00:43 字数 424 浏览 1 评论 0原文

我引用这个答案(强调我的):

查看 ContractClass 和 ContractClassFor 属性。这允许您在单独的程序集中编写带有代码协定的类。这使您可以将合约用于开发工作,不会使您的代码混乱,并且也意味着您不必使用实时代码部署合约

  1. 为什么您不希望合同已部署?

  2. 从最佳实践的角度来看,合同是否严格用于开发和质量控制?

I am referencing this answer (emphasis mine):

Have a look at the ContractClass and ContractClassFor attributes. This allows you to write classes with the code contracts in separate assemblies. This allows you to have the contracts available for dev work, doesn't clutter your code and also means you don't have to deploy the contracts with the live code

  1. Why would you not want the contracts deployed?

  2. Are contracts, from a best-practices point-of-view, strictly for development and quality control?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半仙 2024-10-24 11:00:43
  1. 您通常不想在发布版本上部署后置条件合约。这是为了确保您不会让使用您的程序集的人遇到由您负责的错误。我确信还有其他原因,但这是我想到的第一个原因。

  2. 目前,据我所知,关于代码契约还没有单一的最佳实践观点。使用代码契约有不同的方法(在代码契约用户手册中进行了描述),并且每种方法都有其自己的特定准则。

正如我在评论中所述,您引用的答案也不完全正确。

  1. You generally don't want to deploy postcondition contracts on release builds. This is to make sure that you don't confront people using your assemblies with errors that are your responsibility. I'm sure there are other reasons, but this is the first one that pops to my mind.

  2. Currently, there is no single best-practices point-of-view that I know of regarding Code Contracts. There are different ways to use Code Contracts ( which are described in the Code Contracts User Manual ), and each one has it's own specific guidelines.

The answer you're referencing is also not completely correct, as I've stated in the comments.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文