<?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: The OCP kata</title>
	<atom:link href="http://matteo.vaccari.name/blog/archives/293/feed" rel="self" type="application/rss+xml" />
	<link>http://matteo.vaccari.name/blog/archives/293</link>
	<description>Extreme enthusiasm</description>
	<lastBuildDate>Wed, 21 Jul 2010 13:35:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Extreme Enthusiasm &#187; Blog Archive &#187; The Rock-Scissors-Paper OCP Dojo</title>
		<link>http://matteo.vaccari.name/blog/archives/293/comment-page-1#comment-93396</link>
		<dc:creator>Extreme Enthusiasm &#187; Blog Archive &#187; The Rock-Scissors-Paper OCP Dojo</dc:creator>
		<pubDate>Mon, 12 Jul 2010 15:19:51 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=293#comment-93396</guid>
		<description>[...] kata was meant to be executed with the OCP Dojo rules. I will use Ruby today, because I want to take a break from Java. But the solution will not [...]</description>
		<content:encoded><![CDATA[<p>[...] kata was meant to be executed with the OCP Dojo rules. I will use Ruby today, because I want to take a break from Java. But the solution will not [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tonyx</title>
		<link>http://matteo.vaccari.name/blog/archives/293/comment-page-1#comment-93089</link>
		<dc:creator>Tonyx</dc:creator>
		<pubDate>Tue, 02 Mar 2010 00:24:28 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=293#comment-93089</guid>
		<description>Ciao Matteo,
there is an implementation in c#:
http://github.com/tonyx/katabowling

Ciao.</description>
		<content:encoded><![CDATA[<p>Ciao Matteo,<br />
there is an implementation in c#:<br />
<a href="http://github.com/tonyx/katabowling" rel="nofollow">http://github.com/tonyx/katabowling</a></p>
<p>Ciao.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Extreme Enthusiasm &#187; Blog Archive &#187; Report of the first run of the OCP kata</title>
		<link>http://matteo.vaccari.name/blog/archives/293/comment-page-1#comment-93072</link>
		<dc:creator>Extreme Enthusiasm &#187; Blog Archive &#187; Report of the first run of the OCP kata</dc:creator>
		<pubDate>Tue, 23 Feb 2010 19:49:25 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=293#comment-93072</guid>
		<description>[...] prepared such a good presentation mentioning, among other things, the &#8220;OCP Kata&#8221; of my earlier blog post. The &#8220;Open Closed Principle&#8221; says that we should be able to add new feature by adding [...]</description>
		<content:encoded><![CDATA[<p>[...] prepared such a good presentation mentioning, among other things, the &#8220;OCP Kata&#8221; of my earlier blog post. The &#8220;Open Closed Principle&#8221; says that we should be able to add new feature by adding [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 84° Extreme Programming User Group di Milano &#124; Geek Agenda</title>
		<link>http://matteo.vaccari.name/blog/archives/293/comment-page-1#comment-93069</link>
		<dc:creator>84° Extreme Programming User Group di Milano &#124; Geek Agenda</dc:creator>
		<pubDate>Sun, 21 Feb 2010 13:51:13 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=293#comment-93069</guid>
		<description>[...] Randori: a coppie ci si alternerà al proiettore per risolvere un semplice problema, in modalità OCP; non è obbligatorio partecipare alla coding session,ma si può semplicemente assistere allo [...]</description>
		<content:encoded><![CDATA[<p>[...] Randori: a coppie ci si alternerà al proiettore per risolvere un semplice problema, in modalità OCP; non è obbligatorio partecipare alla coding session,ma si può semplicemente assistere allo [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Giordano Scalzo&#39;s Personal Blog &#187; Milano XpUg January Coding Dojo</title>
		<link>http://matteo.vaccari.name/blog/archives/293/comment-page-1#comment-93060</link>
		<dc:creator>Giordano Scalzo&#39;s Personal Blog &#187; Milano XpUg January Coding Dojo</dc:creator>
		<pubDate>Sat, 06 Feb 2010 14:06:04 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=293#comment-93060</guid>
		<description>[...] As introduction I prepared a little presentation, mainly with the aim to clarify the &#8220;Ocp Way&#8221; to do katas, as conceived by Matteo Vaccari in his blog: XpUg Coding Dojo: KataYahtzee in [...]</description>
		<content:encoded><![CDATA[<p>[...] As introduction I prepared a little presentation, mainly with the aim to clarify the &#8220;Ocp Way&#8221; to do katas, as conceived by Matteo Vaccari in his blog: XpUg Coding Dojo: KataYahtzee in [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matteo</title>
		<link>http://matteo.vaccari.name/blog/archives/293/comment-page-1#comment-93047</link>
		<dc:creator>matteo</dc:creator>
		<pubDate>Mon, 18 Jan 2010 17:32:02 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=293#comment-93047</guid>
		<description>Hi Franco, thanks for your feedback :)

First let me say that this is an exercise, and it&#039;s focused on one single aspect of OOD, namely the OCP.  I&#039;m not saying we should work like this all the time :-)

Now, let me clarify the &quot;not reworking&quot; thing.  In an ideal world, I should be able to accept a new requirement by creating a new class, and injecting it in the system by changing the &quot;main&quot; or the &quot;factory&quot; of the system.  It would be even better if I could add new behaviour simply by configuring and instantiating existing objects.  

For instance, take the bowling example.  If you have all your scoring rules in a chain of responsibility, you could add the &quot;strike&quot; scoring rule by creating a new StrikeScoreRule class and injecting the object in the system:

BowlingGame create() {
  Rolls rolls = new Rolls();
  List&lt;Rule&gt; rules = Arrays.asList(
    new StrikeRule(rolls),
    new SpareRule(rolls),
    new SumOfTwoRollsRule(rolls));
  
  return new BowlingGame(rolls, rules);
}

Suppose now that they ask you to implement &quot;Martian Bowling&quot;, where you have a maximum of three rolls per frame.  You might implement it by creating a SumOfThreeRolls class, and changing the factory like this:


BowlingGame create() {
  Rolls rolls = new Rolls();
  List&lt;Rule&gt; rules = Arrays.asList(
    new StrikeRule(rolls),
    new SpareRule(rolls),
    new SumOfThreeRollsRule(rolls));
  
  return new BowlingGame(rolls, rules);
}

or you might have a flexible object that can act as both the SumOfTwoRollsRule or the SumOfThreeRollsRule like this:

BowlingGame create() {
  Rolls rolls = new Rolls();
  List&lt;Rule&gt; rules = Arrays.asList(
    new StrikeRule(rolls),
    new SpareRule(rolls),
    new SumOfSomeRollsRule(3, rolls));
  
  return new BowlingGame(rolls, rules);
}

Now you ask, what if I am not living in an ideal world, and I cannot simply add new behaviour without reworking everything?  And this is the common case!  In my opinion, what you could do then is to first refactor everything *as if* you had foreseen the new requirement.  You refactor until you can apply the OCP.  Then you insert the new requirement, and it just &quot;slides in&quot; like magic.

I think it&#039;s even better to wait until you have an actual requirement, before you make everything super-flexible.  Otherwise you run the risk of making everything too flexible, that is, to over-engineer.</description>
		<content:encoded><![CDATA[<p>Hi Franco, thanks for your feedback :)</p>
<p>First let me say that this is an exercise, and it&#8217;s focused on one single aspect of OOD, namely the OCP.  I&#8217;m not saying we should work like this all the time :-)</p>
<p>Now, let me clarify the &#8220;not reworking&#8221; thing.  In an ideal world, I should be able to accept a new requirement by creating a new class, and injecting it in the system by changing the &#8220;main&#8221; or the &#8220;factory&#8221; of the system.  It would be even better if I could add new behaviour simply by configuring and instantiating existing objects.  </p>
<p>For instance, take the bowling example.  If you have all your scoring rules in a chain of responsibility, you could add the &#8220;strike&#8221; scoring rule by creating a new StrikeScoreRule class and injecting the object in the system:</p>
<p>BowlingGame create() {<br />
  Rolls rolls = new Rolls();<br />
  List<rule> rules = Arrays.asList(<br />
    new StrikeRule(rolls),<br />
    new SpareRule(rolls),<br />
    new SumOfTwoRollsRule(rolls));</p>
<p>  return new BowlingGame(rolls, rules);<br />
}</p>
<p>Suppose now that they ask you to implement &#8220;Martian Bowling&#8221;, where you have a maximum of three rolls per frame.  You might implement it by creating a SumOfThreeRolls class, and changing the factory like this:</p>
<p>BowlingGame create() {<br />
  Rolls rolls = new Rolls();<br />
  List</rule><rule> rules = Arrays.asList(<br />
    new StrikeRule(rolls),<br />
    new SpareRule(rolls),<br />
    new SumOfThreeRollsRule(rolls));</p>
<p>  return new BowlingGame(rolls, rules);<br />
}</p>
<p>or you might have a flexible object that can act as both the SumOfTwoRollsRule or the SumOfThreeRollsRule like this:</p>
<p>BowlingGame create() {<br />
  Rolls rolls = new Rolls();<br />
  List</rule><rule> rules = Arrays.asList(<br />
    new StrikeRule(rolls),<br />
    new SpareRule(rolls),<br />
    new SumOfSomeRollsRule(3, rolls));</p>
<p>  return new BowlingGame(rolls, rules);<br />
}</p>
<p>Now you ask, what if I am not living in an ideal world, and I cannot simply add new behaviour without reworking everything?  And this is the common case!  In my opinion, what you could do then is to first refactor everything *as if* you had foreseen the new requirement.  You refactor until you can apply the OCP.  Then you insert the new requirement, and it just &#8220;slides in&#8221; like magic.</p>
<p>I think it&#8217;s even better to wait until you have an actual requirement, before you make everything super-flexible.  Otherwise you run the risk of making everything too flexible, that is, to over-engineer.</rule></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Franco Lombardo</title>
		<link>http://matteo.vaccari.name/blog/archives/293/comment-page-1#comment-93046</link>
		<dc:creator>Franco Lombardo</dc:creator>
		<pubDate>Fri, 15 Jan 2010 08:06:54 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=293#comment-93046</guid>
		<description>Matteo,

good exercise: we must do it at XP UG Milan! :-)

Now some notes. You say 
&quot;1. compose functionality out of existing objects&quot;: that&#039;s OK.

&quot;2. avoid reworking existing code&quot;: please, could you explain this? I mean, in your example, at each step you do need to modify some part of the existing code: the BowlingGameFactory, the BowlingGame...
To be honest, in the Open Close Principle what I don&#039;t believe in is the &quot;Close&quot; part. Meyer, in it&#039;s original book, thought to implement it mainly via inheritance. But, as in the beginning of your post, &quot;favor composition over inheritance&quot; it&#039;s a good rule!
To use composition, you must have designed some &quot;injection&quot; point for new behaviors: in your example, the Rolls interface could contain new behaviors, but you need to modify all your classes to accept this injection. Now your code is &quot;closed&quot; to change in this direction, but as soon as new change directions will arise, probably you will need to rework the existing codebase.

Thanks

Bye

Franco</description>
		<content:encoded><![CDATA[<p>Matteo,</p>
<p>good exercise: we must do it at XP UG Milan! :-)</p>
<p>Now some notes. You say<br />
&#8220;1. compose functionality out of existing objects&#8221;: that&#8217;s OK.</p>
<p>&#8220;2. avoid reworking existing code&#8221;: please, could you explain this? I mean, in your example, at each step you do need to modify some part of the existing code: the BowlingGameFactory, the BowlingGame&#8230;<br />
To be honest, in the Open Close Principle what I don&#8217;t believe in is the &#8220;Close&#8221; part. Meyer, in it&#8217;s original book, thought to implement it mainly via inheritance. But, as in the beginning of your post, &#8220;favor composition over inheritance&#8221; it&#8217;s a good rule!<br />
To use composition, you must have designed some &#8220;injection&#8221; point for new behaviors: in your example, the Rolls interface could contain new behaviors, but you need to modify all your classes to accept this injection. Now your code is &#8220;closed&#8221; to change in this direction, but as soon as new change directions will arise, probably you will need to rework the existing codebase.</p>
<p>Thanks</p>
<p>Bye</p>
<p>Franco</p>
]]></content:encoded>
	</item>
</channel>
</rss>
