<?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: Top 5 object programming commandments</title>
	<atom:link href="http://cogitas.net/blog/2010/05/16/top-5-object-programming-commandments/feed/" rel="self" type="application/rss+xml" />
	<link>http://cogitas.net/blog/2010/05/16/top-5-object-programming-commandments/</link>
	<description>Web design and programming blog</description>
	<lastBuildDate>Wed, 10 Aug 2011 18:48:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Nat</title>
		<link>http://cogitas.net/blog/2010/05/16/top-5-object-programming-commandments/comment-page-1/#comment-51</link>
		<dc:creator>Nat</dc:creator>
		<pubDate>Mon, 17 May 2010 21:02:35 +0000</pubDate>
		<guid isPermaLink="false">http://cogitas.net/blog/?p=56#comment-51</guid>
		<description>Kevin - of course, other languages count but as I am a Java programmer, it isn&#039;t surprising that my views reflect my language of choice ;)</description>
		<content:encoded><![CDATA[<p>Kevin &#8211; of course, other languages count but as I am a Java programmer, it isn&#8217;t surprising that my views reflect my language of choice <img src='http://cogitas.net/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Wright</title>
		<link>http://cogitas.net/blog/2010/05/16/top-5-object-programming-commandments/comment-page-1/#comment-50</link>
		<dc:creator>Kevin Wright</dc:creator>
		<pubDate>Mon, 17 May 2010 20:18:33 +0000</pubDate>
		<guid isPermaLink="false">http://cogitas.net/blog/?p=56#comment-50</guid>
		<description>1 &amp; 2 - fair enough, this is just plain common sense

5 - Likewise, but the example quoted is just a single case of the larger &quot;separation of concerns&quot; best practice

3 - Looks like a smell.  It harms both extensibility and testability.  If an object has both public and private behaviour then (in most cases) it usually indicates that the private stuff should be broken out into a second &quot;helper&quot; object, which should itself have public methods

4 - Is actually an anti-pattern.  By initialising member variables in the constructor you can make them final, and therefore make the object immutable, which is a very good practice to get into.  If the object is so large as to make this cumbersome then it probably does too much and should be refactored.  Alternatively you&#039;re probably ready to look at languages with less boilerplate.

Finally.  This obviously isn&#039;t about &quot;programming&quot;, it&#039;s about &quot;JAVA programming&quot;.  Try applying any of these commandments to Lisp, or F#, or Haskell - do such languages not also count?</description>
		<content:encoded><![CDATA[<p>1 &amp; 2 &#8211; fair enough, this is just plain common sense</p>
<p>5 &#8211; Likewise, but the example quoted is just a single case of the larger &#8220;separation of concerns&#8221; best practice</p>
<p>3 &#8211; Looks like a smell.  It harms both extensibility and testability.  If an object has both public and private behaviour then (in most cases) it usually indicates that the private stuff should be broken out into a second &#8220;helper&#8221; object, which should itself have public methods</p>
<p>4 &#8211; Is actually an anti-pattern.  By initialising member variables in the constructor you can make them final, and therefore make the object immutable, which is a very good practice to get into.  If the object is so large as to make this cumbersome then it probably does too much and should be refactored.  Alternatively you&#8217;re probably ready to look at languages with less boilerplate.</p>
<p>Finally.  This obviously isn&#8217;t about &#8220;programming&#8221;, it&#8217;s about &#8220;JAVA programming&#8221;.  Try applying any of these commandments to Lisp, or F#, or Haskell &#8211; do such languages not also count?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nat</title>
		<link>http://cogitas.net/blog/2010/05/16/top-5-object-programming-commandments/comment-page-1/#comment-49</link>
		<dc:creator>Nat</dc:creator>
		<pubDate>Mon, 17 May 2010 17:16:35 +0000</pubDate>
		<guid isPermaLink="false">http://cogitas.net/blog/?p=56#comment-49</guid>
		<description>Danny - point taken about libraries but may I say that if a library doesn&#039;t let you change the input/output source, it is actually poor design.

I think methods should be divided in two categories - methods that return a value of some kind and methods that operate on the variables. Methods that return a value should not operate on variables at the same time (they should call another method to do it) and should therefore be public. Methods that operate on variables should be private, because objects should operate on themselves and not on other objects. It might seem like a strict viewpoint but let it slide and you&#039;ll be confronted with a system where several objects modify another object via calling that kind of method and it will be a mess (I know, I&#039;ve done it several times!).</description>
		<content:encoded><![CDATA[<p>Danny &#8211; point taken about libraries but may I say that if a library doesn&#8217;t let you change the input/output source, it is actually poor design.</p>
<p>I think methods should be divided in two categories &#8211; methods that return a value of some kind and methods that operate on the variables. Methods that return a value should not operate on variables at the same time (they should call another method to do it) and should therefore be public. Methods that operate on variables should be private, because objects should operate on themselves and not on other objects. It might seem like a strict viewpoint but let it slide and you&#8217;ll be confronted with a system where several objects modify another object via calling that kind of method and it will be a mess (I know, I&#8217;ve done it several times!).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Danny</title>
		<link>http://cogitas.net/blog/2010/05/16/top-5-object-programming-commandments/comment-page-1/#comment-48</link>
		<dc:creator>Danny</dc:creator>
		<pubDate>Mon, 17 May 2010 16:49:59 +0000</pubDate>
		<guid isPermaLink="false">http://cogitas.net/blog/?p=56#comment-48</guid>
		<description>I think you took &quot;private is good&quot; too far.  Private variables in the context of data encapsulation is a positive.  However, there is a tendency, especially among libraries, for all non-&quot;vital&quot; methods to be made private.  This is often a real barrier to extensibility.  Perhaps the entire class does what I want but one of the &#039;helper functions&#039; incorrectly assumes that it should be reading configuration from /path/a.properties.  Like any good open-source user, I file a bug with the project, but this leaves me no ability to fix the problem short of subclassing, overwriting the *calling* method so that it calls *my* fixed method instead -- this requires a full copy-paste of the original function just I can&#039;t fix a private method via subclassing.  If it were &#039;protected&#039;, I could subclass it and revert my changes once the bug is fixed in the next version.</description>
		<content:encoded><![CDATA[<p>I think you took &#8220;private is good&#8221; too far.  Private variables in the context of data encapsulation is a positive.  However, there is a tendency, especially among libraries, for all non-&#8221;vital&#8221; methods to be made private.  This is often a real barrier to extensibility.  Perhaps the entire class does what I want but one of the &#8216;helper functions&#8217; incorrectly assumes that it should be reading configuration from /path/a.properties.  Like any good open-source user, I file a bug with the project, but this leaves me no ability to fix the problem short of subclassing, overwriting the *calling* method so that it calls *my* fixed method instead &#8212; this requires a full copy-paste of the original function just I can&#8217;t fix a private method via subclassing.  If it were &#8216;protected&#8217;, I could subclass it and revert my changes once the bug is fixed in the next version.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

