<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Code Contracts #3: Contract checking</title>
	<atom:link href="http://www.minddriven.de/index.php/technology/dot-net/code-contracts-contract-checking/feed" rel="self" type="application/rss+xml" />
	<link>http://www.minddriven.de/index.php/technology/dot-net/code-contracts-contract-checking</link>
	<description>Matthias Jauernig -- .NET technology, architecture and design</description>
	<lastBuildDate>Thu, 02 Feb 2012 06:42:23 +0100</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
	<item>
		<title>By: Code Contracts #5: Method purity &#124; .NET ... out of the dark</title>
		<link>http://www.minddriven.de/index.php/technology/dot-net/code-contracts-contract-checking/comment-page-1#comment-1198</link>
		<dc:creator>Code Contracts #5: Method purity &#124; .NET ... out of the dark</dc:creator>
		<pubDate>Sat, 02 May 2009 17:15:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.leading-edge-dev.de/?p=315#comment-1198</guid>
		<description>[...] In the first parts of this series I gave you some basic information about Code Contracts, the static and dynamic checker, the code rewriter and how implications can be modelled. This day&#8217;s blog post comes up with [...]</description>
		<content:encoded><![CDATA[<p>[...] In the first parts of this series I gave you some basic information about Code Contracts, the static and dynamic checker, the code rewriter and how implications can be modelled. This day&#8217;s blog post comes up with [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthias Jauernig</title>
		<link>http://www.minddriven.de/index.php/technology/dot-net/code-contracts-contract-checking/comment-page-1#comment-213</link>
		<dc:creator>Matthias Jauernig</dc:creator>
		<pubDate>Sun, 22 Mar 2009 16:29:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.leading-edge-dev.de/?p=315#comment-213</guid>
		<description>Hi AJ,

That&#039;s a good point. As I stated, Code Contracts are no master solution. Contracts define behavior on code, but those definitions could be insufficient or incorrect as well. This brings unit tests to mind.

And I see the problem you mentioned: duplicating program logic in contracts is not a suitable way. In limited cases this would work and you can model implications in the form of: &quot;if input is x, output should by y&quot;. But in more complex cases (take complex algorithms, for example a sorting algorithm), this would be no solution. I agree with you, that in this case a unit test is the correct answer. The problem of unit test remains: it can only test one input/output pair (or a limited set), but in the case of expressing semantic logic/behavior it is the right tool. Thank you for pushing in your ideas on that, I&#039;ll further make my mind up on that and your opinions are welcome everytime.

Cheers, Matthias</description>
		<content:encoded><![CDATA[<p>Hi AJ,</p>
<p>That&#8217;s a good point. As I stated, Code Contracts are no master solution. Contracts define behavior on code, but those definitions could be insufficient or incorrect as well. This brings unit tests to mind.</p>
<p>And I see the problem you mentioned: duplicating program logic in contracts is not a suitable way. In limited cases this would work and you can model implications in the form of: &#8220;if input is x, output should by y&#8221;. But in more complex cases (take complex algorithms, for example a sorting algorithm), this would be no solution. I agree with you, that in this case a unit test is the correct answer. The problem of unit test remains: it can only test one input/output pair (or a limited set), but in the case of expressing semantic logic/behavior it is the right tool. Thank you for pushing in your ideas on that, I&#8217;ll further make my mind up on that and your opinions are welcome everytime.</p>
<p>Cheers, Matthias</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AJ.NET</title>
		<link>http://www.minddriven.de/index.php/technology/dot-net/code-contracts-contract-checking/comment-page-1#comment-198</link>
		<dc:creator>AJ.NET</dc:creator>
		<pubDate>Fri, 20 Mar 2009 07:49:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.leading-edge-dev.de/?p=315#comment-198</guid>
		<description>Hi folks,

sorry to contradict you somewhat, but IMO code contracts and unit testing have a somewhat more complex relationship than your comments indicated.

Granted, there is a certain amount of overlap and some unittests could quite well be expressed as contracts (because soo far they were the only means to check those contracts). But then, contracts are about stating and ensuring certain guarantees about the code, while unittests are about behaviour or the correctness of the implemented algorithm. 

To make my point clear, have a look at this example (pseudo code!):

double Sqrt(double x)
{
	requires: x&gt;=0
	ensures: ret&gt;=0 
	ensures: ret&lt;x &#124;&#124; ret==0

	return x/2
}


This would be formally correct and state all the sensible guarantess, but dividing by two is clearly not the same as a square root. To ensure the correctness, you would still need a unit test, checking if x==Sqrt(x)*Sqrt(x). And you would not want to dupplicate the logic of your code as a contract.


Just my 0,02€
AJ.NET</description>
		<content:encoded><![CDATA[<p>Hi folks,</p>
<p>sorry to contradict you somewhat, but IMO code contracts and unit testing have a somewhat more complex relationship than your comments indicated.</p>
<p>Granted, there is a certain amount of overlap and some unittests could quite well be expressed as contracts (because soo far they were the only means to check those contracts). But then, contracts are about stating and ensuring certain guarantees about the code, while unittests are about behaviour or the correctness of the implemented algorithm. </p>
<p>To make my point clear, have a look at this example (pseudo code!):</p>
<p>double Sqrt(double x)<br />
{<br />
	requires: x&gt;=0<br />
	ensures: ret&gt;=0<br />
	ensures: ret&lt;x || ret==0</p>
<p>	return x/2<br />
}</p>
<p>This would be formally correct and state all the sensible guarantess, but dividing by two is clearly not the same as a square root. To ensure the correctness, you would still need a unit test, checking if x==Sqrt(x)*Sqrt(x). And you would not want to dupplicate the logic of your code as a contract.</p>
<p>Just my 0,02€<br />
AJ.NET</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthias Jauernig</title>
		<link>http://www.minddriven.de/index.php/technology/dot-net/code-contracts-contract-checking/comment-page-1#comment-185</link>
		<dc:creator>Matthias Jauernig</dc:creator>
		<pubDate>Tue, 17 Mar 2009 18:56:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.leading-edge-dev.de/?p=315#comment-185</guid>
		<description>Hi Pop,

You&#039;re right. Contracts are more expressive than unit tests in the sense, that with the static checker you have verification over all code parts and all value ranges. With unit tests you&#039;ve just some test cases and need defined value pairs (input and expected output) for that. But often you forget something to test...

Regarding the combination of TDD and DbC I want to make my mind up in the following days and weeks for myself. DbC has not only advantages! The behavior that you defined is guaranteed, but who says that this is the behavior that you or a user expected? It&#039;s very likely that you forget contracts or define wrong contracts or have errors in your contracts... and then? Testing can do very well in this case, I think. Another problem is the complexity of defining contracs. Many not so advanced developers would be overwhelmed by that. Let me do a little bit more research on DbC+TDD, I hope to have some stronger ideas soon...</description>
		<content:encoded><![CDATA[<p>Hi Pop,</p>
<p>You&#8217;re right. Contracts are more expressive than unit tests in the sense, that with the static checker you have verification over all code parts and all value ranges. With unit tests you&#8217;ve just some test cases and need defined value pairs (input and expected output) for that. But often you forget something to test&#8230;</p>
<p>Regarding the combination of TDD and DbC I want to make my mind up in the following days and weeks for myself. DbC has not only advantages! The behavior that you defined is guaranteed, but who says that this is the behavior that you or a user expected? It&#8217;s very likely that you forget contracts or define wrong contracts or have errors in your contracts&#8230; and then? Testing can do very well in this case, I think. Another problem is the complexity of defining contracs. Many not so advanced developers would be overwhelmed by that. Let me do a little bit more research on DbC+TDD, I hope to have some stronger ideas soon&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pop Catalin</title>
		<link>http://www.minddriven.de/index.php/technology/dot-net/code-contracts-contract-checking/comment-page-1#comment-178</link>
		<dc:creator>Pop Catalin</dc:creator>
		<pubDate>Mon, 16 Mar 2009 14:07:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.leading-edge-dev.de/?p=315#comment-178</guid>
		<description>Excellent series of posts, I don&#039;t know what effect will all this have on testing methodologies, but code contracts seem like unit testing on steroids. What you also get is formal verification that your contracts have 100% coverage of all code variants, which is the strongest point of Code Contracts imo.</description>
		<content:encoded><![CDATA[<p>Excellent series of posts, I don&#8217;t know what effect will all this have on testing methodologies, but code contracts seem like unit testing on steroids. What you also get is formal verification that your contracts have 100% coverage of all code variants, which is the strongest point of Code Contracts imo.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

