通缉:代码合约的真实世界范例
问题描述:
有没有人有一个真实的例子,使用契约式设计和特别是代码合同?
Does anyone has a real world example of using Design by Contract and particularly Code contracts ?
我可以使用简单的if来确保对象不是null但是我想看一个更多 complected 现实世界验证的例子...
i could use a simple if to make sure object is not null but i'd like to see an example of more complected real world verifications...
谢谢!
Dan
答
大多数基类库现在都有合同,可能是一个很好的起点。安装编辑器扩展,在查看类详细信息时显示合同。 可能一个好的起点是IList,因为它突出了前
和后期条件。
Most of the base class libraries now have contracts and are probably a good place to start. Install the editor extension that shows you the contracts when you view class details. Probably a good place to start is IList as it highlight the both pre and post conditions.