<?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: Partitioned Complexity</title>
	<atom:link href="http://lostechies.com/evanhoff/2008/04/01/partitioned-complexity/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/evanhoff/2008/04/01/partitioned-complexity/</link>
	<description>Just another LosTechies site</description>
	<lastBuildDate>Thu, 11 Sep 2008 15:52:56 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Joe Gutierrez</title>
		<link>http://lostechies.com/evanhoff/2008/04/01/partitioned-complexity/#comment-74</link>
		<dc:creator>Joe Gutierrez</dc:creator>
		<pubDate>Thu, 03 Apr 2008 16:01:34 +0000</pubDate>
		<guid isPermaLink="false">/blogs/evan_hoff/archive/2008/04/01/partitioned-complexity.aspx#comment-74</guid>
		<description>It&#039;s ok. What I was going for was a &#039;partitioning of the if logic space&#039; remove duplication. What it doesn&#039;t partition is change. For example what if we needed to add a 6 sided die reader? where are the change points.

1&gt; The readers
2&gt; If logic.

If a requirement came in for the die, then and only then would I try to deal with those change points.

note: Originally I had the if logic in the Coin Reader class.</description>
		<content:encoded><![CDATA[<p>It&#8217;s ok. What I was going for was a &#8216;partitioning of the if logic space&#8217; remove duplication. What it doesn&#8217;t partition is change. For example what if we needed to add a 6 sided die reader? where are the change points.</p>
<p>1> The readers<br />
2> If logic.</p>
<p>If a requirement came in for the die, then and only then would I try to deal with those change points.</p>
<p>note: Originally I had the if logic in the Coin Reader class.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Evan</title>
		<link>http://lostechies.com/evanhoff/2008/04/01/partitioned-complexity/#comment-73</link>
		<dc:creator>Evan</dc:creator>
		<pubDate>Wed, 02 Apr 2008 19:31:15 +0000</pubDate>
		<guid isPermaLink="false">/blogs/evan_hoff/archive/2008/04/01/partitioned-complexity.aspx#comment-73</guid>
		<description>@Joe

Nice.  What you just did was partition the complexity.

Now, I&#039;ll ask you a question, is it a good partition? If so, why? (evil grin)</description>
		<content:encoded><![CDATA[<p>@Joe</p>
<p>Nice.  What you just did was partition the complexity.</p>
<p>Now, I&#8217;ll ask you a question, is it a good partition? If so, why? (evil grin)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe Gutierrez</title>
		<link>http://lostechies.com/evanhoff/2008/04/01/partitioned-complexity/#comment-72</link>
		<dc:creator>Joe Gutierrez</dc:creator>
		<pubDate>Wed, 02 Apr 2008 17:35:24 +0000</pubDate>
		<guid isPermaLink="false">/blogs/evan_hoff/archive/2008/04/01/partitioned-complexity.aspx#comment-72</guid>
		<description>It would seem at least in the example that it is a matter of abstraction. In the code there is a missing abstraction, treating each reader as separate entities. Try treating them as a collection:

    [TestFixture]
    public class ComplexityTest
    {
        [Test]
        public void Tail()
        {
            CoinReader pennyReader = CoinReader.PennyReader;

            IList readerList = new ArrayList();

            readerList.Add(pennyReader);

            Display display = new Display(readerList);

            RandomService.value = true;
            Assert.AreEqual(&quot;Penny is Tails\r\n&quot;, display.GetMessage());
        }


        [Test]
        public void Head()
        {
            CoinReader dimeReader = CoinReader.DimeReader;

            IList readerList = new ArrayList();

            readerList.Add(dimeReader);

            Display display = new Display(readerList);

            RandomService.value = true;
            Assert.AreEqual(&quot;Dime is Tails\r\n&quot;, display.GetMessage());
        }

        [Test]
        public void AllTails()
        {
            CoinReader pennyReader = CoinReader.PennyReader;
            CoinReader dimeReader = CoinReader.DimeReader;

            IList readerList = new ArrayList();

            readerList.Add(pennyReader);
            readerList.Add(dimeReader);

            Display display = new Display(readerList);

            RandomService.value = true;
            Assert.AreEqual(&quot;Penny is Tails\r\nDime is Tails\r\n&quot;, display.GetMessage());
        }

        [Test]
        public void AllHeads()
        {
            CoinReader pennyReader = CoinReader.PennyReader;
            CoinReader dimeReader = CoinReader.DimeReader;

            IList readerList = new ArrayList();

            readerList.Add(pennyReader);
            readerList.Add(dimeReader);

            Display display = new Display(readerList);

            RandomService.value = false;
            Assert.AreEqual(&quot;Penny is Heads\r\nDime is Heads\r\n&quot;, display.GetMessage());
        }

        [Test]
        public void AllSuperHeads()
        {
            CoinReader pennyReader = CoinReader.PennyReader;
            CoinReader dimeReader = CoinReader.DimeReader;
            CoinReader quarterReader = CoinReader.QuarterReader;

            IList readerList = new ArrayList();

            readerList.Add(pennyReader);
            readerList.Add(dimeReader);
            readerList.Add(quarterReader);

            Display display = new Display(readerList);

            RandomService.value = false;
            Assert.AreEqual(&quot;Penny is Heads\r\nDime is Heads\r\nQuarter is Heads\r\n&quot;, display.GetMessage());
        }
    }

    public class RandomService
    {
        public static bool value;

        public bool GetRandom()
        {
            return value;
        }
    }

    public class CoinReader
    {
        private string readerType;
        private bool coinStatus;

        private RandomService randomService;

        private CoinReader(string type, RandomService service)
        {
            readerType = type;
            randomService = service;
        }

        public void Read()
        {
            coinStatus = randomService.GetRandom();
        }

        public string GetReaderType()
        {
            return readerType;
        }

        public bool GetStatus()
        {
            return coinStatus;
        }

        public static CoinReader DimeReader = new CoinReader(&quot;Dime&quot;, new  RandomService());
        public static CoinReader PennyReader = new CoinReader(&quot;Penny&quot;, new RandomService());
        public static CoinReader QuarterReader = new CoinReader(&quot;Quarter&quot;, new RandomService());
    }

    public class Display
    {
        private IList readerList = null;

        public Display(IList list)
        {
            readerList = list;
        }

        public string GetMessage()
        {
            string message = string.Empty;
            string status = string.Empty;

            foreach (CoinReader reader in readerList)
            {
                reader.Read();
                status = reader.GetStatus() ? &quot;Tails&quot; : &quot;Heads&quot;;
                message += reader.GetReaderType() + &quot; is &quot; + status + Environment.NewLine; ;
            }
            return message;
        }
    }
</description>
		<content:encoded><![CDATA[<p>It would seem at least in the example that it is a matter of abstraction. In the code there is a missing abstraction, treating each reader as separate entities. Try treating them as a collection:</p>
<p>    [TestFixture]<br />
    public class ComplexityTest<br />
    {<br />
        [Test]<br />
        public void Tail()<br />
        {<br />
            CoinReader pennyReader = CoinReader.PennyReader;</p>
<p>            IList readerList = new ArrayList();</p>
<p>            readerList.Add(pennyReader);</p>
<p>            Display display = new Display(readerList);</p>
<p>            RandomService.value = true;<br />
            Assert.AreEqual(&#8220;Penny is Tails\r\n&#8221;, display.GetMessage());<br />
        }</p>
<p>        [Test]<br />
        public void Head()<br />
        {<br />
            CoinReader dimeReader = CoinReader.DimeReader;</p>
<p>            IList readerList = new ArrayList();</p>
<p>            readerList.Add(dimeReader);</p>
<p>            Display display = new Display(readerList);</p>
<p>            RandomService.value = true;<br />
            Assert.AreEqual(&#8220;Dime is Tails\r\n&#8221;, display.GetMessage());<br />
        }</p>
<p>        [Test]<br />
        public void AllTails()<br />
        {<br />
            CoinReader pennyReader = CoinReader.PennyReader;<br />
            CoinReader dimeReader = CoinReader.DimeReader;</p>
<p>            IList readerList = new ArrayList();</p>
<p>            readerList.Add(pennyReader);<br />
            readerList.Add(dimeReader);</p>
<p>            Display display = new Display(readerList);</p>
<p>            RandomService.value = true;<br />
            Assert.AreEqual(&#8220;Penny is Tails\r\nDime is Tails\r\n&#8221;, display.GetMessage());<br />
        }</p>
<p>        [Test]<br />
        public void AllHeads()<br />
        {<br />
            CoinReader pennyReader = CoinReader.PennyReader;<br />
            CoinReader dimeReader = CoinReader.DimeReader;</p>
<p>            IList readerList = new ArrayList();</p>
<p>            readerList.Add(pennyReader);<br />
            readerList.Add(dimeReader);</p>
<p>            Display display = new Display(readerList);</p>
<p>            RandomService.value = false;<br />
            Assert.AreEqual(&#8220;Penny is Heads\r\nDime is Heads\r\n&#8221;, display.GetMessage());<br />
        }</p>
<p>        [Test]<br />
        public void AllSuperHeads()<br />
        {<br />
            CoinReader pennyReader = CoinReader.PennyReader;<br />
            CoinReader dimeReader = CoinReader.DimeReader;<br />
            CoinReader quarterReader = CoinReader.QuarterReader;</p>
<p>            IList readerList = new ArrayList();</p>
<p>            readerList.Add(pennyReader);<br />
            readerList.Add(dimeReader);<br />
            readerList.Add(quarterReader);</p>
<p>            Display display = new Display(readerList);</p>
<p>            RandomService.value = false;<br />
            Assert.AreEqual(&#8220;Penny is Heads\r\nDime is Heads\r\nQuarter is Heads\r\n&#8221;, display.GetMessage());<br />
        }<br />
    }</p>
<p>    public class RandomService<br />
    {<br />
        public static bool value;</p>
<p>        public bool GetRandom()<br />
        {<br />
            return value;<br />
        }<br />
    }</p>
<p>    public class CoinReader<br />
    {<br />
        private string readerType;<br />
        private bool coinStatus;</p>
<p>        private RandomService randomService;</p>
<p>        private CoinReader(string type, RandomService service)<br />
        {<br />
            readerType = type;<br />
            randomService = service;<br />
        }</p>
<p>        public void Read()<br />
        {<br />
            coinStatus = randomService.GetRandom();<br />
        }</p>
<p>        public string GetReaderType()<br />
        {<br />
            return readerType;<br />
        }</p>
<p>        public bool GetStatus()<br />
        {<br />
            return coinStatus;<br />
        }</p>
<p>        public static CoinReader DimeReader = new CoinReader(&#8220;Dime&#8221;, new  RandomService());<br />
        public static CoinReader PennyReader = new CoinReader(&#8220;Penny&#8221;, new RandomService());<br />
        public static CoinReader QuarterReader = new CoinReader(&#8220;Quarter&#8221;, new RandomService());<br />
    }</p>
<p>    public class Display<br />
    {<br />
        private IList readerList = null;</p>
<p>        public Display(IList list)<br />
        {<br />
            readerList = list;<br />
        }</p>
<p>        public string GetMessage()<br />
        {<br />
            string message = string.Empty;<br />
            string status = string.Empty;</p>
<p>            foreach (CoinReader reader in readerList)<br />
            {<br />
                reader.Read();<br />
                status = reader.GetStatus() ? &#8220;Tails&#8221; : &#8220;Heads&#8221;;<br />
                message += reader.GetReaderType() + &#8221; is &#8221; + status + Environment.NewLine; ;<br />
            }<br />
            return message;<br />
        }<br />
    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe Gutierrez</title>
		<link>http://lostechies.com/evanhoff/2008/04/01/partitioned-complexity/#comment-71</link>
		<dc:creator>Joe Gutierrez</dc:creator>
		<pubDate>Wed, 02 Apr 2008 13:47:17 +0000</pubDate>
		<guid isPermaLink="false">/blogs/evan_hoff/archive/2008/04/01/partitioned-complexity.aspx#comment-71</guid>
		<description>Nice. So what! Where is the implementation showing the partition in the example? gutzofter@yahoo.com</description>
		<content:encoded><![CDATA[<p>Nice. So what! Where is the implementation showing the partition in the example? <a href="mailto:gutzofter@yahoo.com">gutzofter@yahoo.com</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
