开发者

Is it bad to deploy code contracts into a production environment?

开发者 https://www.devze.com 2023-02-10 18:42 出处:网络
I am referencing this answer (emphasis mine): Have a look at the ContractClass and ContractClassFor attributes. This allows you to write classe开发者_Python百科s with the code contracts in separate

I am referencing this answer (emphasis mine):

Have a look at the ContractClass and ContractClassFor attributes. This allows you to write classe开发者_Python百科s 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?


  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.

0

精彩评论

暂无评论...
验证码 换一张
取 消