<?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: Open/closed design principle</title>
	<atom:link href="http://www.rubenswieringa.com/blog/openclosed-design-principle/feed" rel="self" type="application/rss+xml" />
	<link>http://www.rubenswieringa.com/blog/openclosed-design-principle</link>
	<description>Ruben Swieringa on Actionscript and a whole lot of other stuff..</description>
	<lastBuildDate>Wed, 14 Jul 2010 10:22:27 +0200</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Ruben</title>
		<link>http://www.rubenswieringa.com/blog/openclosed-design-principle/comment-page-1#comment-22807</link>
		<dc:creator>Ruben</dc:creator>
		<pubDate>Fri, 28 Mar 2008 09:36:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubenswieringa.com/blog/openclosed-design-principle#comment-22807</guid>
		<description>Yeah sounds pretty sensible, thanks man. :)</description>
		<content:encoded><![CDATA[<p>Yeah sounds pretty sensible, thanks man. <img src='http://www.rubenswieringa.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Blanco</title>
		<link>http://www.rubenswieringa.com/blog/openclosed-design-principle/comment-page-1#comment-22794</link>
		<dc:creator>John Blanco</dc:creator>
		<pubDate>Fri, 28 Mar 2008 02:31:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubenswieringa.com/blog/openclosed-design-principle#comment-22794</guid>
		<description>My rule of thumb is to use protected for data that simple-access, that is, just holding a value.  I use private for fields that are complex-access, that is, has dependencies.

For example, if you were keeping track of a bunch of personal information, protected is fine.  If you were keeping track of the length or amount of some chunk of data, private.  

That said, most of my stuff I leave protected.</description>
		<content:encoded><![CDATA[<p>My rule of thumb is to use protected for data that simple-access, that is, just holding a value.  I use private for fields that are complex-access, that is, has dependencies.</p>
<p>For example, if you were keeping track of a bunch of personal information, protected is fine.  If you were keeping track of the length or amount of some chunk of data, private.  </p>
<p>That said, most of my stuff I leave protected.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ruben</title>
		<link>http://www.rubenswieringa.com/blog/openclosed-design-principle/comment-page-1#comment-11221</link>
		<dc:creator>Ruben</dc:creator>
		<pubDate>Tue, 20 Nov 2007 09:19:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubenswieringa.com/blog/openclosed-design-principle#comment-11221</guid>
		<description>Right on Michael, though my intention has never been to tell anyone that making your vars public or protected was in fact wrong. I&#039;m also not completely sure if I agree that applying the open/closed principle is dangerous by definition, as a matter of fact I reckon that it might in fact be a pretty good point to start from, with of course a line of exceptions to the rule.</description>
		<content:encoded><![CDATA[<p>Right on Michael, though my intention has never been to tell anyone that making your vars public or protected was in fact wrong. I&#8217;m also not completely sure if I agree that applying the open/closed principle is dangerous by definition, as a matter of fact I reckon that it might in fact be a pretty good point to start from, with of course a line of exceptions to the rule.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Avila</title>
		<link>http://www.rubenswieringa.com/blog/openclosed-design-principle/comment-page-1#comment-11045</link>
		<dc:creator>Michael Avila</dc:creator>
		<pubDate>Mon, 19 Nov 2007 00:10:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubenswieringa.com/blog/openclosed-design-principle#comment-11045</guid>
		<description>It&#039;s dangerous to apply open/closed to designing classes in general. 

Generally you want your code to clearly convey your intent. You should be able to &#039;read&#039; what your code is doing. We try to use strong metaphors so that knowledge transfer about what a class does can be achieved by using things which we may already be familiar with. We group classes with similar notions using naming conventions (ie SubclassSuperclass). Even classes are organized in hierarchies so that we can better describe what we are trying to do. All of these things we do so that we, as well as other people, have a better time using our code after we have written it. 

Ideally you would expect the same thing from how your code executes. You try to keep the consequences of changing some aspect of the class only within the class itself, which makes it relatively easier to make changes because the effects are immediately apparent. Allowing a field to be modified from anywhere within the application creates a situation where making a change can have consequences anywhere within the application, which in turn makes that change more difficult to make.

Introducing fields which can be accessed directly (either public, or protected) isn&#039;t wrong, it just has it&#039;s effects.  It can be made much more apparent in the case of a code base that is distributed and likely to evolve. After a field has been released and is accessible you must support it in any updates. I suppose you could just remove it, but then I&#039;d be dissapointed :(

By making a field public you are also providing explicit information about how a class structures it&#039;s state, which makes it more difficult to change if you ever need to (which is probably pretty likely).

If you are asking yourself whether or not a set of properties (or even just one) should be accessible (or even exist within that class), it may be an indication that there is a bigger design problem, but then again getting done and going home is important too.

Meh I don&#039;t know, as usual Ruben, just me rambling :-P</description>
		<content:encoded><![CDATA[<p>It&#8217;s dangerous to apply open/closed to designing classes in general. </p>
<p>Generally you want your code to clearly convey your intent. You should be able to &#8216;read&#8217; what your code is doing. We try to use strong metaphors so that knowledge transfer about what a class does can be achieved by using things which we may already be familiar with. We group classes with similar notions using naming conventions (ie SubclassSuperclass). Even classes are organized in hierarchies so that we can better describe what we are trying to do. All of these things we do so that we, as well as other people, have a better time using our code after we have written it. </p>
<p>Ideally you would expect the same thing from how your code executes. You try to keep the consequences of changing some aspect of the class only within the class itself, which makes it relatively easier to make changes because the effects are immediately apparent. Allowing a field to be modified from anywhere within the application creates a situation where making a change can have consequences anywhere within the application, which in turn makes that change more difficult to make.</p>
<p>Introducing fields which can be accessed directly (either public, or protected) isn&#8217;t wrong, it just has it&#8217;s effects.  It can be made much more apparent in the case of a code base that is distributed and likely to evolve. After a field has been released and is accessible you must support it in any updates. I suppose you could just remove it, but then I&#8217;d be dissapointed <img src='http://www.rubenswieringa.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>By making a field public you are also providing explicit information about how a class structures it&#8217;s state, which makes it more difficult to change if you ever need to (which is probably pretty likely).</p>
<p>If you are asking yourself whether or not a set of properties (or even just one) should be accessible (or even exist within that class), it may be an indication that there is a bigger design problem, but then again getting done and going home is important too.</p>
<p>Meh I don&#8217;t know, as usual Ruben, just me rambling <img src='http://www.rubenswieringa.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ruben</title>
		<link>http://www.rubenswieringa.com/blog/openclosed-design-principle/comment-page-1#comment-11031</link>
		<dc:creator>Ruben</dc:creator>
		<pubDate>Sun, 18 Nov 2007 21:26:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubenswieringa.com/blog/openclosed-design-principle#comment-11031</guid>
		<description>That&#039;s actually a very valid point. Regarding releasing control upon protected vars, you can take the pros and leave the cons by creating a private setter and a protected (or even public) getter as to make a property read-only for subclasses.

Unfortunately in &lt;abbr&gt;AS3&lt;/abbr&gt; there&#039;s a bug that throws a compile-time error when corresponding getters and setters don&#039;t have the same namespace attribute:
&lt;a href=&quot;http://www.rubenswieringa.com/blog/ambiguous-reference-bug-for-namespaces-in-flex&quot; rel=&quot;nofollow&quot;&gt;Ambiguous reference bug for namespaces in Flex&lt;/a&gt;

Of course you could consider working with actual methods (&lt;em&gt;function getMyProperty()&lt;/em&gt; instead of &lt;em&gt;function get myProperty()&lt;/em&gt;), but I suppose that would kind of prevent data-binding from being applied (not completely sure there though), as far as Flex goes that is.</description>
		<content:encoded><![CDATA[<p>That&#8217;s actually a very valid point. Regarding releasing control upon protected vars, you can take the pros and leave the cons by creating a private setter and a protected (or even public) getter as to make a property read-only for subclasses.</p>
<p>Unfortunately in <abbr>AS3</abbr> there&#8217;s a bug that throws a compile-time error when corresponding getters and setters don&#8217;t have the same namespace attribute:<br />
<a href="http://www.rubenswieringa.com/blog/ambiguous-reference-bug-for-namespaces-in-flex" rel="nofollow">Ambiguous reference bug for namespaces in Flex</a></p>
<p>Of course you could consider working with actual methods (<em>function getMyProperty()</em> instead of <em>function get myProperty()</em>), but I suppose that would kind of prevent data-binding from being applied (not completely sure there though), as far as Flex goes that is.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gerben Wiersma</title>
		<link>http://www.rubenswieringa.com/blog/openclosed-design-principle/comment-page-1#comment-11015</link>
		<dc:creator>Gerben Wiersma</dc:creator>
		<pubDate>Sun, 18 Nov 2007 17:33:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubenswieringa.com/blog/openclosed-design-principle#comment-11015</guid>
		<description>I believe that most private variables can be made accessible with property functions (the so-called getter&#039;s and setter&#039;s) If you add this functionality to your class then extending classes  don&#039;t have to touch the private parts ;) 
I&#039;m always a bit cautious adding protected variables, because you then release your control upon that variable. May in the future this variable change (ie: you want it to be 10% less) then the extending classes won&#039;t pickup on this change, therefor building further upon bad data. With getter&#039;s and setter&#039;s you simply can change with it returns.
Your thoughts about this?</description>
		<content:encoded><![CDATA[<p>I believe that most private variables can be made accessible with property functions (the so-called getter&#8217;s and setter&#8217;s) If you add this functionality to your class then extending classes  don&#8217;t have to touch the private parts <img src='http://www.rubenswieringa.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
I&#8217;m always a bit cautious adding protected variables, because you then release your control upon that variable. May in the future this variable change (ie: you want it to be 10% less) then the extending classes won&#8217;t pickup on this change, therefor building further upon bad data. With getter&#8217;s and setter&#8217;s you simply can change with it returns.<br />
Your thoughts about this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ruben</title>
		<link>http://www.rubenswieringa.com/blog/openclosed-design-principle/comment-page-1#comment-10995</link>
		<dc:creator>Ruben</dc:creator>
		<pubDate>Sun, 18 Nov 2007 13:55:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubenswieringa.com/blog/openclosed-design-principle#comment-10995</guid>
		<description>Spot on, in fact that was part of what started the discussion in the first place. Of course most (if not all) components in the Flex framework have their protected methods (commitProperties, createChildren, etc.), but almost all non-public variables are declared private (instead of protected).
This makes the protected methods a lot less useful seeing that added features in most cases will have to be completely new, instead of functionality that is built upon existing functionality in the original class..</description>
		<content:encoded><![CDATA[<p>Spot on, in fact that was part of what started the discussion in the first place. Of course most (if not all) components in the Flex framework have their protected methods (commitProperties, createChildren, etc.), but almost all non-public variables are declared private (instead of protected).<br />
This makes the protected methods a lot less useful seeing that added features in most cases will have to be completely new, instead of functionality that is built upon existing functionality in the original class..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith Peters</title>
		<link>http://www.rubenswieringa.com/blog/openclosed-design-principle/comment-page-1#comment-10993</link>
		<dc:creator>Keith Peters</dc:creator>
		<pubDate>Sun, 18 Nov 2007 13:43:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubenswieringa.com/blog/openclosed-design-principle#comment-10993</guid>
		<description>Yes, I think most people get the closed for modification part, but probably often don&#039;t think enough about the open for extension part. In AS3, this means judicious use of protected methods and vars. I have heard several complaints about the Flex framework where certain members are private, which makes it hard to extend a particular component or class.</description>
		<content:encoded><![CDATA[<p>Yes, I think most people get the closed for modification part, but probably often don&#8217;t think enough about the open for extension part. In AS3, this means judicious use of protected methods and vars. I have heard several complaints about the Flex framework where certain members are private, which makes it hard to extend a particular component or class.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
