<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="http://commons.oreilly.com/wiki/skins/common/feed.css?97"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title>Write Small Functions Using Examples - Revision history</title>
		<link>http://commons.oreilly.com/wiki/index.php?title=Write_Small_Functions_Using_Examples&amp;action=history</link>
		<description>Revision history for this page on the wiki</description>
		<language>en</language>
		<generator>MediaWiki 1.11.0</generator>
		<lastBuildDate>Tue, 21 May 2013 16:28:18 GMT</lastBuildDate>
		<item>
			<title>KeithBraithwaite at 13:20, 5 August 2009</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=Write_Small_Functions_Using_Examples&amp;diff=25104&amp;oldid=prev</link>
			<description>&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 13:20, 5 August 2009&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 6:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 6:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;     libertyCount &amp;lt; 2&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;     libertyCount &amp;lt; 2&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is larger than it looks. A mathematical function can be understood as a set, some subset of the Cartesian product of the sets that are its domain (here, &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;) and range (here, &amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt;). If those sets of values were the same size as in Java then there would be &amp;lt;code&amp;gt;2L*(Integer.MAX_VALUE+(-1L*Integer.MIN_VALUE)+1L)&amp;lt;/code&amp;gt; or 8,589,934,592 members in the set &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;&amp;amp;times;&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt;. Half of these are members of the subset that is our function, so to &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;produce compelling &lt;/del&gt;evidence that our function is correct we would need to check around  4.3&amp;amp;times;10&amp;lt;sup&amp;gt;9&amp;lt;/sup&amp;gt; examples. &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is larger than it looks. A mathematical function can be understood as a set, some subset of the Cartesian product of the sets that are its domain (here, &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;) and range (here, &amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt;). If those sets of values were the same size as in Java then there would be &amp;lt;code&amp;gt;2L*(Integer.MAX_VALUE+(-1L*Integer.MIN_VALUE)+1L)&amp;lt;/code&amp;gt; or 8,589,934,592 members in the set &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;&amp;amp;times;&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt;. Half of these are members of the subset that is our function, so to &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;provide complete &lt;/ins&gt;evidence that our function is correct we would need to check around  4.3&amp;amp;times;10&amp;lt;sup&amp;gt;9&amp;lt;/sup&amp;gt; examples. &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is the essence of the claim that test cannot prove the absence of bugs. Tests can demonstrate the presence of features, though. But still we have this issue of size. &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is the essence of the claim that test cannot prove the absence of bugs. Tests can demonstrate the presence of features, though. But still we have this issue of size. &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wikicontent:diff:version:1.11a:oldid:25096:newid:25104 --&gt;
&lt;/table&gt;</description>
			<pubDate>Wed, 05 Aug 2009 13:20:57 GMT</pubDate>			<dc:creator>KeithBraithwaite</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:Write_Small_Functions_Using_Examples</comments>		</item>
		<item>
			<title>KeithBraithwaite: tweaks post email conversation</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=Write_Small_Functions_Using_Examples&amp;diff=25096&amp;oldid=prev</link>
			<description>&lt;p&gt;tweaks post email conversation&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 13:05, 5 August 2009&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 4:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 4:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; boolean atari(int libertyCount)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; boolean atari(int libertyCount)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;     &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;if &lt;/del&gt;libertyCount &amp;lt; 2&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;     libertyCount &amp;lt; 2&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;         true&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;         false&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is larger than it looks. A mathematical function can be understood as a set, some subset of the Cartesian product of the sets that are its domain (here, &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;) and range (here, &amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt;). If those sets of values were the same size as in Java then there would be &amp;lt;code&amp;gt;2L*(Integer.MAX_VALUE+(-1L*Integer.MIN_VALUE)+1L)&amp;lt;/code&amp;gt; or 8,589,934,592 members in the set &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;&amp;amp;times;&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt;. Half of these are members of the subset that is our function, so to produce compelling evidence that our function is correct we would need to check around  4.3&amp;amp;times;10&amp;lt;sup&amp;gt;9&amp;lt;/sup&amp;gt; examples. &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is larger than it looks. A mathematical function can be understood as a set, some subset of the Cartesian product of the sets that are its domain (here, &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;) and range (here, &amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt;). If those sets of values were the same size as in Java then there would be &amp;lt;code&amp;gt;2L*(Integer.MAX_VALUE+(-1L*Integer.MIN_VALUE)+1L)&amp;lt;/code&amp;gt; or 8,589,934,592 members in the set &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;&amp;amp;times;&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt;. Half of these are members of the subset that is our function, so to produce compelling evidence that our function is correct we would need to check around  4.3&amp;amp;times;10&amp;lt;sup&amp;gt;9&amp;lt;/sup&amp;gt; examples. &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 16:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 14:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; LibertyCount = {1,2,3,4} &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; LibertyCount = {1,2,3,4} &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; boolean atari(LibertyCount libertyCount)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; boolean atari(LibertyCount libertyCount)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;     &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;if &lt;/del&gt;libertyCount == 1&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;     libertyCount == 1&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;         true&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;         false&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is much more tractable: The function computed is now a set with at most eight members. In fact, four checked examples would constitute evidence of complete certainty that the function is correct. This is one reason why it's a good idea to use types closely related to the problem domain to write programs, rather than native types. Using domain–inspired types can often make our functions much smaller.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is much more tractable: The function computed is now a set with at most eight members. In fact, four checked examples would constitute evidence of complete certainty that the function is correct. This is one reason why it's a good idea to use types closely related to the problem domain to write programs, rather than native types. Using domain–inspired types can often make our functions much smaller&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;. One way to find out what those types should be is to find the examples to check in problem domain terms, before writing the function&lt;/ins&gt;. &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;by [[Keith Braithwaite]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;by [[Keith Braithwaite]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wikicontent:diff:version:1.11a:oldid:25094:newid:25096 --&gt;
&lt;/table&gt;</description>
			<pubDate>Wed, 05 Aug 2009 13:05:54 GMT</pubDate>			<dc:creator>KeithBraithwaite</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:Write_Small_Functions_Using_Examples</comments>		</item>
		<item>
			<title>Kevlin at 11:11, 5 August 2009</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=Write_Small_Functions_Using_Examples&amp;diff=25094&amp;oldid=prev</link>
			<description>&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 11:11, 5 August 2009&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;For example, in the game of Go there is a condition called ''atari'' in which a player's stones may be captured by their opponent: A stone with two or more free spaces adjacent to it (called ''liberties'') is not in atari. It can be tricky to count how many liberties a stone has, but determining atari is easy if that is known. We might begin by writing a function like this: &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;For example, in the game of Go there is a condition called ''atari'' in which a player's stones may be captured by their opponent: A stone with two or more free spaces adjacent to it (called ''liberties'') is not in atari. It can be tricky to count how many liberties a stone has, but determining atari is easy if that is known. We might begin by writing a function like this: &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; boolean atari (int libertyCount)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; boolean atari(int libertyCount)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;     if libertyCount &amp;lt; 2&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;     if libertyCount &amp;lt; 2&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         true&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         true&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wikicontent:diff:version:1.11a:oldid:25092:newid:25094 --&gt;
&lt;/table&gt;</description>
			<pubDate>Wed, 05 Aug 2009 11:11:44 GMT</pubDate>			<dc:creator>Kevlin</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:Write_Small_Functions_Using_Examples</comments>		</item>
		<item>
			<title>Kevlin at 11:06, 5 August 2009</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=Write_Small_Functions_Using_Examples&amp;diff=25092&amp;oldid=prev</link>
			<description>&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 11:06, 5 August 2009&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;We would like to write code that is correct, and have evidence on hand that it is correct. It can help with both issues is to think about the &amp;quot;size&amp;quot; of a functions. Not in the sense of the amount of code that implements a function&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;, &lt;/del&gt;although that is interesting&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;, &lt;/del&gt;but rather the size of the mathematical function that our code manifests.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;We would like to write code that is correct, and have evidence on hand that it is correct. It can help with both issues is to think about the &amp;quot;size&amp;quot; of a functions. Not in the sense of the amount of code that implements a function &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;amp;mdash; &lt;/ins&gt;although that is interesting &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;amp;mdash; &lt;/ins&gt;but rather the size of the mathematical function that our code manifests.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;For example, in the game of Go there is a condition called ''atari'' in which a player's stones may be captured by their opponent: &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;a &lt;/del&gt;stone with two or more free spaces adjacent to it (called ''liberties'') is not in atari. It can be tricky to count how many liberties a stone has, but &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;knowing that &lt;/del&gt;determining atari is easy. We might begin by writing a function like this: &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;For example, in the game of Go there is a condition called ''atari'' in which a player's stones may be captured by their opponent: &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;A &lt;/ins&gt;stone with two or more free spaces adjacent to it (called ''liberties'') is not in atari. It can be tricky to count how many liberties a stone has, but determining atari is easy &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;if that is known&lt;/ins&gt;. We might begin by writing a function like this: &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; boolean atari (int libertyCount)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; boolean atari (int libertyCount)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 13:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 13:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The problem domain helps us out. The nature of Go means that number of liberties of a stone is not any &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;, but exactly one of {1,2,3,4}. So we could alternatively write:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The problem domain helps us out. The nature of Go means that number of liberties of a stone is not any &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;, but exactly one of {1,2,3,4}. So we could alternatively write:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; LibertyCount = {1,2,3,4} &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; LibertyCount = {1,2,3,4} &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; boolean atari(LibertyCount libertyCount)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; boolean atari(LibertyCount libertyCount)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 18:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 19:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         true&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         true&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         false&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         false&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is much more tractable&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;, the &lt;/del&gt;function computed is now a set with at most &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;8 &lt;/del&gt;members. In fact, &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;4 &lt;/del&gt;checked examples would constitute evidence of complete certainty that the function is correct. This is one reason why &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;its &lt;/del&gt;a good idea to use types closely related to the problem domain to write programs, rather than native types. Using domain–inspired types can often make our functions much smaller.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is much more tractable&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;: The &lt;/ins&gt;function computed is now a set with at most &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;eight &lt;/ins&gt;members. In fact, &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;four &lt;/ins&gt;checked examples would constitute evidence of complete certainty that the function is correct. This is one reason why &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;it's &lt;/ins&gt;a good idea to use types closely related to the problem domain to write programs, rather than native types. Using domain–inspired types can often make our functions much smaller.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;by [[Keith Braithwaite]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;This work is licensed under a&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;[http://creativecommons.org/licenses/by/3.0/us/ Creative Commons Attribution 3] &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Back to [[97 Things Every Programmer Should Know]] home page&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wikicontent:diff:version:1.11a:oldid:25086:newid:25092 --&gt;
&lt;/table&gt;</description>
			<pubDate>Wed, 05 Aug 2009 11:06:39 GMT</pubDate>			<dc:creator>Kevlin</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:Write_Small_Functions_Using_Examples</comments>		</item>
		<item>
			<title>KeithBraithwaite: copyedit</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=Write_Small_Functions_Using_Examples&amp;diff=25086&amp;oldid=prev</link>
			<description>&lt;p&gt;copyedit&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 18:09, 2 August 2009&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 18:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 18:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         true&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         true&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         false&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         false&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is much more tractable, the function &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;is &lt;/del&gt;computed is now a set with at most 8 members, 4 checked examples would constitute evidence of complete certainty that the function is correct. This is one reason why its a good idea to use types closely related to the problem domain to write programs, rather than native types. Using domain–inspired types can often make our functions much smaller.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is much more tractable, the function computed is now a set with at most 8 members&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;. In fact&lt;/ins&gt;, 4 checked examples would constitute evidence of complete certainty that the function is correct. This is one reason why its a good idea to use types closely related to the problem domain to write programs, rather than native types. Using domain–inspired types can often make our functions much smaller.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wikicontent:diff:version:1.11a:oldid:25085:newid:25086 --&gt;
&lt;/table&gt;</description>
			<pubDate>Sun, 02 Aug 2009 18:09:59 GMT</pubDate>			<dc:creator>KeithBraithwaite</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:Write_Small_Functions_Using_Examples</comments>		</item>
		<item>
			<title>KeithBraithwaite: copyedit</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=Write_Small_Functions_Using_Examples&amp;diff=25085&amp;oldid=prev</link>
			<description>&lt;p&gt;copyedit&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 18:02, 2 August 2009&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 8:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 8:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         false&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         false&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is larger than it looks. A mathematical function can be understood as a set, some subset of the Cartesian product of the sets that are its domain &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;and range. Here the domain is the set of &lt;/del&gt;&amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;values &lt;/del&gt;and &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;the &lt;/del&gt;range &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;that of &lt;/del&gt;&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;values&lt;/del&gt;. If &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;these &lt;/del&gt;were the same size as in Java then there would be &amp;lt;code&amp;gt;2L*(Integer.MAX_VALUE+(-1L*Integer.MIN_VALUE)+1L)&amp;lt;/code&amp;gt; or 8,589,934,592 members in the set &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;&amp;amp;times;&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt;. &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Only half &lt;/del&gt;of these are members of the subset that is our function, so to produce compelling evidence that our function is correct we would need to check around  4.3&amp;amp;times;10&amp;lt;sup&amp;gt;9&amp;lt;/sup&amp;gt; examples. &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is larger than it looks. A mathematical function can be understood as a set, some subset of the Cartesian product of the sets that are its domain &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;(here, &lt;/ins&gt;&amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;) &lt;/ins&gt;and range &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;(here, &lt;/ins&gt;&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;)&lt;/ins&gt;. If &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;those sets of values &lt;/ins&gt;were the same size as in Java then there would be &amp;lt;code&amp;gt;2L*(Integer.MAX_VALUE+(-1L*Integer.MIN_VALUE)+1L)&amp;lt;/code&amp;gt; or 8,589,934,592 members in the set &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;&amp;amp;times;&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt;. &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Half &lt;/ins&gt;of these are members of the subset that is our function, so to produce compelling evidence that our function is correct we would need to check around  4.3&amp;amp;times;10&amp;lt;sup&amp;gt;9&amp;lt;/sup&amp;gt; examples. &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is the essence of the claim that test cannot prove the absence of bugs. Tests can demonstrate the presence of features, though. But still we have this issue of size. &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is the essence of the claim that test cannot prove the absence of bugs. Tests can demonstrate the presence of features, though. But still we have this issue of size. &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The problem domain helps us out. The nature of Go means that number of liberties is not any &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;, but exactly one of {1,2,3,4}. So we could alternatively write:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The problem domain helps us out. The nature of Go means that number of liberties &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;of a stone &lt;/ins&gt;is not any &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;, but exactly one of {1,2,3,4}. So we could alternatively write:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; LibertyCount = {1,2,3,4} &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; LibertyCount = {1,2,3,4} &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; boolean atari(LibertyCount libertyCount)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; boolean atari(LibertyCount libertyCount)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wikicontent:diff:version:1.11a:oldid:25083:newid:25085 --&gt;
&lt;/table&gt;</description>
			<pubDate>Sun, 02 Aug 2009 18:02:24 GMT</pubDate>			<dc:creator>KeithBraithwaite</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:Write_Small_Functions_Using_Examples</comments>		</item>
		<item>
			<title>KeithBraithwaite at 15:16, 2 August 2009</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=Write_Small_Functions_Using_Examples&amp;diff=25083&amp;oldid=prev</link>
			<description>&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 15:16, 2 August 2009&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 13:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 13:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The problem domain helps us out. The nature of Go means that number of liberties is not any &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;, but exactly one of {1,2,3,4}. So we could alternatively write:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The problem domain helps us out. The nature of Go means that number of liberties is not any &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;, but exactly one of {1,2,3,4}. So we could alternatively write:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; LibertyCount = {1,2,3,4}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; LibertyCount = {1,2,3,4} &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; boolean atari(LibertyCount libertyCount)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; boolean atari(LibertyCount libertyCount)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;     if libertyCount &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt; 2&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;     if libertyCount &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;== 1&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         true&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         true&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         false&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         false&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is much more tractable, the function is computed is now a set with at most 8 members, 4 checked examples would constitute evidence of complete certainty that the function is correct. This is one reason why its a good idea to use types closely related to the problem domain to write programs, rather than native types. Using domain–inspired types can often make our functions much smaller.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is much more tractable, the function is computed is now a set with at most 8 members, 4 checked examples would constitute evidence of complete certainty that the function is correct. This is one reason why its a good idea to use types closely related to the problem domain to write programs, rather than native types. Using domain–inspired types can often make our functions much smaller.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wikicontent:diff:version:1.11a:oldid:25082:newid:25083 --&gt;
&lt;/table&gt;</description>
			<pubDate>Sun, 02 Aug 2009 15:16:28 GMT</pubDate>			<dc:creator>KeithBraithwaite</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:Write_Small_Functions_Using_Examples</comments>		</item>
		<item>
			<title>KeithBraithwaite at 15:14, 2 August 2009</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=Write_Small_Functions_Using_Examples&amp;diff=25082&amp;oldid=prev</link>
			<description>&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 15:14, 2 August 2009&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;We would like to write code that is correct, and have evidence on hand that it is correct. It can help with both issues is to think about the &amp;quot;size&amp;quot; of a functions. Not in the sense of the amount of code that implements a function, although that is interesting, but rather the size of the mathematical function that our code manifests.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;We would like to write code that is correct, and have evidence on hand that it is correct. It can help with both issues is to think about the &amp;quot;size&amp;quot; of a functions. Not in the sense of the amount of code that implements a function, although that is interesting, but rather the size of the mathematical function that our code manifests.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;For example, in the game of Go there is a condition called ''atari'' in which a player's stones may be captured by their opponent&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;. The rule is that &lt;/del&gt;a stone with two or more free spaces adjacent to it (&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;these are &lt;/del&gt;called ''liberties'') is not in atari. &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;While it &lt;/del&gt;can be &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;surprisingly &lt;/del&gt;tricky to count how many liberties a stone has, &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;once we know &lt;/del&gt;that &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;working out if the stone is in &lt;/del&gt;atari is easy. We might begin by writing a function &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;(in pseudo–code) &lt;/del&gt;like this: &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;For example, in the game of Go there is a condition called ''atari'' in which a player's stones may be captured by their opponent&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;: &lt;/ins&gt;a stone with two or more free spaces adjacent to it (called ''liberties'') is not in atari. &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;It &lt;/ins&gt;can be tricky to count how many liberties a stone has, &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;but knowing &lt;/ins&gt;that &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;determining &lt;/ins&gt;atari is easy. We might begin by writing a function like this: &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; boolean atari (int libertyCount)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; boolean atari (int libertyCount)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 8:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 8:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         false&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         false&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;function &lt;/del&gt;is larger than it looks. A mathematical function can be understood as a set, &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;specifically &lt;/del&gt;some subset of the Cartesian product of &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;all &lt;/del&gt;the sets that are its domain and range. Here the domain is the set of &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;all &lt;/del&gt;&amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; values and the range &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;is the set &lt;/del&gt;of &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;all &lt;/del&gt;&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; values. If these were the same size as in Java then there would be &amp;lt;code&amp;gt;2L*(Integer.MAX_VALUE+(-1L*Integer.MIN_VALUE)+1L)&amp;lt;/code&amp;gt; or 8,589,934,592 members &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;of &lt;/del&gt;the set &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;&amp;amp;times;&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt;. Only half of these are members of the subset that is our function, &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;but still &lt;/del&gt;to produce compelling evidence that &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;this &lt;/del&gt;function &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;as written &lt;/del&gt;is correct &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;then in principle &lt;/del&gt;we would need to &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;create checked examples for all &lt;/del&gt;4.3&amp;amp;times;10&amp;lt;sup&amp;gt;9&amp;lt;/sup&amp;gt; &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;possible invocations&lt;/del&gt;. &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is larger than it looks. A mathematical function can be understood as a set, some subset of the Cartesian product of the sets that are its domain and range. Here the domain is the set of &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; values and the range &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;that &lt;/ins&gt;of &amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; values. If these were the same size as in Java then there would be &amp;lt;code&amp;gt;2L*(Integer.MAX_VALUE+(-1L*Integer.MIN_VALUE)+1L)&amp;lt;/code&amp;gt; or 8,589,934,592 members &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;in &lt;/ins&gt;the set &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;&amp;amp;times;&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt;. Only half of these are members of the subset that is our function, &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;so &lt;/ins&gt;to produce compelling evidence that &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;our &lt;/ins&gt;function is correct we would need to &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;check around  &lt;/ins&gt;4.3&amp;amp;times;10&amp;lt;sup&amp;gt;9&amp;lt;/sup&amp;gt; &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;examples&lt;/ins&gt;. &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is the essence of the claim that test cannot prove the absence of bugs. Tests can demonstrate the presence of features, though. But still we have this issue of size. &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is the essence of the claim that test cannot prove the absence of bugs. Tests can demonstrate the presence of features, though. But still we have this issue of size. &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 18:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 18:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         true&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         true&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         false&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         false&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is much more tractable, the function is computed is now a set with at most 8 members&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;. In fact&lt;/del&gt;, 4 checked examples would constitute evidence of complete certainty that the function is correct.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is much more tractable, the function is computed is now a set with at most 8 members, 4 checked examples would constitute evidence of complete certainty that the function is correct. This is one reason why its a good idea to use types closely related to the problem domain to write programs, rather than native types. Using domain–inspired types can often make our functions much smaller.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is one reason why its a good idea to use &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;new &lt;/del&gt;types closely related to the problem domain to write programs, rather than &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;use &lt;/del&gt;native types &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;everywhere&lt;/del&gt;. Using domain–inspired types can often make our functions much smaller.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wikicontent:diff:version:1.11a:oldid:25081:newid:25082 --&gt;
&lt;/table&gt;</description>
			<pubDate>Sun, 02 Aug 2009 15:14:02 GMT</pubDate>			<dc:creator>KeithBraithwaite</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:Write_Small_Functions_Using_Examples</comments>		</item>
		<item>
			<title>KeithBraithwaite at 15:06, 2 August 2009</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=Write_Small_Functions_Using_Examples&amp;diff=25081&amp;oldid=prev</link>
			<description>&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 15:06, 2 August 2009&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 8:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 8:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         false&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         false&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This function is larger than it looks. A mathematical function can be understood as a set, specifically some subset of the Cartesian product of all the sets that are its domain and range. Here the domain is the set of all &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; values and the range is the set of all &amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; values. If these were the same size as in Java then there would be &amp;lt;code&amp;gt;2L*(Integer.MAX_VALUE+(-1L*Integer.MIN_VALUE)+1L)&amp;lt;/code&amp;gt; or 8,589,934,592 members of the set &amp;lt;code&amp;gt;int &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;* &lt;/del&gt;boolean&amp;lt;/code&amp;gt;. Only half of these are members of the subset that is our function, but still to produce compelling evidence that this function as written is correct then in principle we would need to create checked examples for all 4.3&amp;amp;times;10&amp;lt;sup&amp;gt;9&amp;lt;/sup&amp;gt; possible invocations. &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This function is larger than it looks. A mathematical function can be understood as a set, specifically some subset of the Cartesian product of all the sets that are its domain and range. Here the domain is the set of all &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; values and the range is the set of all &amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; values. If these were the same size as in Java then there would be &amp;lt;code&amp;gt;2L*(Integer.MAX_VALUE+(-1L*Integer.MIN_VALUE)+1L)&amp;lt;/code&amp;gt; or 8,589,934,592 members of the set &amp;lt;code&amp;gt;int&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/code&amp;gt;&amp;amp;times;&amp;lt;code&amp;gt;&lt;/ins&gt;boolean&amp;lt;/code&amp;gt;. Only half of these are members of the subset that is our function, but still to produce compelling evidence that this function as written is correct then in principle we would need to create checked examples for all 4.3&amp;amp;times;10&amp;lt;sup&amp;gt;9&amp;lt;/sup&amp;gt; possible invocations. &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is the essence of the claim that test cannot prove the absence of bugs. Tests can demonstrate the presence of features, though. But still we have this issue of size. &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is the essence of the claim that test cannot prove the absence of bugs. Tests can demonstrate the presence of features, though. But still we have this issue of size. &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wikicontent:diff:version:1.11a:oldid:25080:newid:25081 --&gt;
&lt;/table&gt;</description>
			<pubDate>Sun, 02 Aug 2009 15:06:28 GMT</pubDate>			<dc:creator>KeithBraithwaite</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:Write_Small_Functions_Using_Examples</comments>		</item>
		<item>
			<title>KeithBraithwaite at 15:05, 2 August 2009</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=Write_Small_Functions_Using_Examples&amp;diff=25080&amp;oldid=prev</link>
			<description>&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 15:05, 2 August 2009&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 8:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 8:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         false&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;         false&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This function is larger than it looks. A mathematical function can be understood as a set, specifically some subset of the Cartesian product of all the sets that are its domain and range. Here the domain is the set of all &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; values and the range is the set of all &amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; values. If these were the same size as in Java then there would be &amp;lt;code&amp;gt;2L * (Integer.MAX_VALUE + (-1L * Integer.MIN_VALUE) + 1L)&amp;lt;/code&amp;gt; or 8,589,934,592 members of the set &amp;lt;code&amp;gt;int * boolean&amp;lt;/code&amp;gt;. Only half of these are members of the subset that is our function, but still to produce compelling evidence that this function as written is correct then in principle we would need to create checked examples for all 4.3&amp;amp;times;10&amp;lt;sup&amp;gt;9&amp;lt;/sup&amp;gt; possible invocations. &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This function is larger than it looks. A mathematical function can be understood as a set, specifically some subset of the Cartesian product of all the sets that are its domain and range. Here the domain is the set of all &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; values and the range is the set of all &amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; values. If these were the same size as in Java then there would be &amp;lt;code&amp;gt;2L*(Integer.MAX_VALUE+(-1L*Integer.MIN_VALUE)+1L)&amp;lt;/code&amp;gt; or 8,589,934,592 members of the set &amp;lt;code&amp;gt;int * boolean&amp;lt;/code&amp;gt;. Only half of these are members of the subset that is our function, but still to produce compelling evidence that this function as written is correct then in principle we would need to create checked examples for all 4.3&amp;amp;times;10&amp;lt;sup&amp;gt;9&amp;lt;/sup&amp;gt; possible invocations. &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is the essence of the claim that test cannot prove the absence of bugs. Tests can demonstrate the presence of features, though. But still we have this issue of size. &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is the essence of the claim that test cannot prove the absence of bugs. Tests can demonstrate the presence of features, though. But still we have this issue of size. &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wikicontent:diff:version:1.11a:oldid:25079:newid:25080 --&gt;
&lt;/table&gt;</description>
			<pubDate>Sun, 02 Aug 2009 15:05:46 GMT</pubDate>			<dc:creator>KeithBraithwaite</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:Write_Small_Functions_Using_Examples</comments>		</item>
	</channel>
</rss>