<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: is private method an antipattern</title>
	<atom:link href="http://monkeyisland.pl/2008/01/05/private-method-antipattern/feed/" rel="self" type="application/rss+xml" />
	<link>http://monkeyisland.pl/2008/01/05/private-method-antipattern/</link>
	<description>about software</description>
	<lastBuildDate>Fri, 11 May 2012 11:03:02 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Tom</title>
		<link>http://monkeyisland.pl/2008/01/05/private-method-antipattern/#comment-3537</link>
		<dc:creator><![CDATA[Tom]]></dc:creator>
		<pubDate>Thu, 08 Jul 2010 13:51:33 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/2008/01/05/private-method-antipattern/#comment-3537</guid>
		<description><![CDATA[I have to agree it is an anti pattern. An anti pattern is: ineffective and/or counterproductive in practice (taken from wiki: http://en.wikipedia.org/wiki/Anti-pattern) So with TDD making a methods private is counter productive as you need to be able to test the method.

I always struggle to come up with an example of when to use private, so whould appreciate if anyone can provide a good one.

If I dont want a function to be called from outside my class I make it protected. Thus giving me or anyone the option to override the function and allow for it to be tested.]]></description>
		<content:encoded><![CDATA[<p>I have to agree it is an anti pattern. An anti pattern is: ineffective and/or counterproductive in practice (taken from wiki: <a href="http://en.wikipedia.org/wiki/Anti-pattern" rel="nofollow">http://en.wikipedia.org/wiki/Anti-pattern</a>) So with TDD making a methods private is counter productive as you need to be able to test the method.</p>
<p>I always struggle to come up with an example of when to use private, so whould appreciate if anyone can provide a good one.</p>
<p>If I dont want a function to be called from outside my class I make it protected. Thus giving me or anyone the option to override the function and allow for it to be tested.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Johannes</title>
		<link>http://monkeyisland.pl/2008/01/05/private-method-antipattern/#comment-3500</link>
		<dc:creator><![CDATA[Johannes]]></dc:creator>
		<pubDate>Thu, 15 Apr 2010 18:40:39 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/2008/01/05/private-method-antipattern/#comment-3500</guid>
		<description><![CDATA[Private methodes are just functions in the object&#039;s scope, and thats exactly what you want to avoid in OOP. So instead of writing private methods, you should create new classes.

Greetings,
Johannes]]></description>
		<content:encoded><![CDATA[<p>Private methodes are just functions in the object&#8217;s scope, and thats exactly what you want to avoid in OOP. So instead of writing private methods, you should create new classes.</p>
<p>Greetings,<br />
Johannes</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: szczepiq</title>
		<link>http://monkeyisland.pl/2008/01/05/private-method-antipattern/#comment-2782</link>
		<dc:creator><![CDATA[szczepiq]]></dc:creator>
		<pubDate>Tue, 26 Feb 2008 14:07:07 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/2008/01/05/private-method-antipattern/#comment-2782</guid>
		<description><![CDATA[First you say that private methods are NEVER an anti-patter. Then you say that static private methods are a bad smell. Make up your mind! :)

I don&#039;t disagree with you in general. I just believe that taking private methods with a pinch of salt has positive effect on OO-thinking. I have a few friends who strongly believe that privacy is an anti-pattern. They all write absolutely awesome code.

Anyway, thanks for an interesting comment.]]></description>
		<content:encoded><![CDATA[<p>First you say that private methods are NEVER an anti-patter. Then you say that static private methods are a bad smell. Make up your mind! :)</p>
<p>I don&#8217;t disagree with you in general. I just believe that taking private methods with a pinch of salt has positive effect on OO-thinking. I have a few friends who strongly believe that privacy is an anti-pattern. They all write absolutely awesome code.</p>
<p>Anyway, thanks for an interesting comment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Radoslaw Maruszewski</title>
		<link>http://monkeyisland.pl/2008/01/05/private-method-antipattern/#comment-2780</link>
		<dc:creator><![CDATA[Radoslaw Maruszewski]]></dc:creator>
		<pubDate>Mon, 25 Feb 2008 10:40:53 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/2008/01/05/private-method-antipattern/#comment-2780</guid>
		<description><![CDATA[Private methods are NEVER an anti-pattern. And they are NOT a bad smell in the code.

The main principles of a good OO design say that one should program to interfaces, not to classes, and that scoping of the class and methods should be as limited as possible. By widening the scope of your private methods you simply break both of these principles. Your unit tests should test the interface of your application (see BDD), and be completely unaware of  the inner implementation.

That said it&#039;s pretty obvious that private methods should follow other principles of OO design. They should be cohesive (bad cohesion is usually the main culprit of lengthy and ugly methods), loosely coupled with other methods (yes, coupling between class methods is also very important), but tightly coupled with class structure (thus private methods which could be declared &#039;static&#039; ARE a bad smell, as they usually don&#039;t belong there).]]></description>
		<content:encoded><![CDATA[<p>Private methods are NEVER an anti-pattern. And they are NOT a bad smell in the code.</p>
<p>The main principles of a good OO design say that one should program to interfaces, not to classes, and that scoping of the class and methods should be as limited as possible. By widening the scope of your private methods you simply break both of these principles. Your unit tests should test the interface of your application (see BDD), and be completely unaware of  the inner implementation.</p>
<p>That said it&#8217;s pretty obvious that private methods should follow other principles of OO design. They should be cohesive (bad cohesion is usually the main culprit of lengthy and ugly methods), loosely coupled with other methods (yes, coupling between class methods is also very important), but tightly coupled with class structure (thus private methods which could be declared &#8216;static&#8217; ARE a bad smell, as they usually don&#8217;t belong there).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: szczepiq</title>
		<link>http://monkeyisland.pl/2008/01/05/private-method-antipattern/#comment-2764</link>
		<dc:creator><![CDATA[szczepiq]]></dc:creator>
		<pubDate>Mon, 14 Jan 2008 23:35:49 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/2008/01/05/private-method-antipattern/#comment-2764</guid>
		<description><![CDATA[Private methods are just an element of language - we should use them smartly to create simple and sexy code. I don&#039;t think they are anti-pattern, too. However, calling them a smell may have a good effect: people will be more likely to refactor when private method gets too big or too ugly. At least I hope so ;)]]></description>
		<content:encoded><![CDATA[<p>Private methods are just an element of language &#8211; we should use them smartly to create simple and sexy code. I don&#8217;t think they are anti-pattern, too. However, calling them a smell may have a good effect: people will be more likely to refactor when private method gets too big or too ugly. At least I hope so ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fijiaaron</title>
		<link>http://monkeyisland.pl/2008/01/05/private-method-antipattern/#comment-2756</link>
		<dc:creator><![CDATA[fijiaaron]]></dc:creator>
		<pubDate>Mon, 07 Jan 2008 16:37:45 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/2008/01/05/private-method-antipattern/#comment-2756</guid>
		<description><![CDATA[I don&#039;t think private methods are an antipattern, but I do think that private methods are really only rarely used with any useful affect.  The typical justification for private methods is so that someone doesn&#039;t reach inside your API and have something that breaks with implementation changes, but that just isn&#039;t the case.  Once upon a time, in Windows people did that because the Win32 API was so broken, but so many people have gotten burned, that they either respect Microsoft&#039;s APIs, or since the APIs themselves change so much, have just abandoned Microsoft.  

Making methods private won&#039;t protect against this, and since in practice it&#039;s more likely that your API changes than your underlying (private) implementation, private methods often don&#039;t make sense in the real world.  There may be some highly structured organizations where it does, but I haven&#039;t seen them.]]></description>
		<content:encoded><![CDATA[<p>I don&#8217;t think private methods are an antipattern, but I do think that private methods are really only rarely used with any useful affect.  The typical justification for private methods is so that someone doesn&#8217;t reach inside your API and have something that breaks with implementation changes, but that just isn&#8217;t the case.  Once upon a time, in Windows people did that because the Win32 API was so broken, but so many people have gotten burned, that they either respect Microsoft&#8217;s APIs, or since the APIs themselves change so much, have just abandoned Microsoft.  </p>
<p>Making methods private won&#8217;t protect against this, and since in practice it&#8217;s more likely that your API changes than your underlying (private) implementation, private methods often don&#8217;t make sense in the real world.  There may be some highly structured organizations where it does, but I haven&#8217;t seen them.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

