如何成熟的是微软code合同框架? [英] How mature is the Microsoft Code Contracts framework?

查看:157
本文介绍了如何成熟的是微软code合同框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

微软最近把自己的 code合同框架,DevLabs与释放商业许可证。我们有兴趣使用它们在我们的项目(主要是C#,一些C ++ / CLI)来逐步取代所有的自定义验证code,但我渴望知道别人有过它,我们承诺之前的经历它,具体是:

Microsoft has recently put a release of their Code Contracts framework on DevLabs with a commercial license. We're interested on using them in our project (mostly C#, some C++/CLI) to gradually replace all the custom validation code, but I'm keen to know about the experience other people have had with it before we commit to it, specifically:

  • 你认为该框架是足够成熟的大而复杂的商业项目?

  • Do you think the framework is sufficiently mature for large and complex commercial projects?

你有没有运行,而使用它变成了什么问题?

What problems have you run into while using it?

有什么好处,你从中得到了什么?

What benefits have you got from it?

它是目前更多的痛苦比它的价值?

Is it currently more pain than it's worth?

我知道这是一个有点主观的问题,因为它需要的意见,但鉴于该框架是.NET 4.0中一个非常显著的一部分,将(可能)改变我们的所有写验证code,我希望的方式这个问题将留给开放积累经验,关于这个问题,以帮助我做出决定的一个具体,可回答的问题:

I realise that this is a somewhat subjective question as it requires opinion, but given that this framework is a very significant part of .NET 4.0 and will (potentially) change the way we all write validation code, I hope that this question will be left open to gather experience on the subject to help me make a decision to a specific, answerable question:

我们是否应该开始使用它下个月?

Should we be starting to use it next month?

请注意,我们不运送一个code API,只是一个网络服务之一,因此对于广大code破坏兼容性的抛出的异常类型而言是不是一个问题。然而,正如我希望更多的人不只是我会从这篇文章,它的答案中受益,解决此方面的任何细节更受欢迎。

Note that we do not ship a code API, only a web service one, so for the majority of code breaking compatibility in terms of the exception type thrown is not a concern. However, as I'm hoping more people than just me will benefit from this post and its answers, any detail around this area is more than welcome.

推荐答案

我一直在摆弄code合同多一些自己的小,但比较复杂的独立项目,这需要一些BCL类继承并用其他的。

I've been playing around with the code contracts some more myself on a small but moderately complex standalone project, which needs to inherit from some BCL classes and use other ones.

该合同的事情似乎伟大的,当你工作在只有自己的code和原始类型完全隔离的环境中,但只要你开始使用BCL类(直到.NET 4.0没有自己合同)验证无法检查他们是否会违反任何要求/保证/不变量,因此你可以得到很多的警告有关潜在不满意的限制。

The contracts thing seems great when you're working in a completely isolated environment with just your own code and primitive types, but as soon as you start using BCL classes (which until .NET 4.0 do not have their own contracts) the verifier cannot check whether they will violate any of the requires/ensures/invariants and so you get a lot of warnings about potentially unsatisfied constraints.

在另一方面,它发现一些无效或可能不满足约束这可能是真实的错误。但它很难找到这些,因为有这么多的噪音,很难找出哪些是你可以修复。这可以通过使用承担机制晚饭preSS从BCL类的警​​告,但这是有点弄巧成拙,因为这些课程将在未来的合同,假设将减少自己的价值。

On the other hand, it does find some invalid or potentially unsatisfied constraints which could be real bugs. But it's very hard to find these because there is so much noise that it's hard to find out which ones you can fix. It's possible to suppress the warnings from the BCL classes by using the assume mechanism, but this is somewhat self-defeating as these classes will have contracts in the future and assumptions will lessen their worth.

所以,我的感觉是,就目前而言,由于在3.5我们正在试图建立一个框架,验证不充分的理解,它可能是值得期待的4.0。

So my feeling is that for now, because in 3.5 we're trying to build on a framework that the verifier does not sufficiently understand, that it's probably worth waiting for 4.0.

这篇关于如何成熟的是微软code合同框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆