<?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: Static Methods are Death to Testability</title>
	<atom:link href="http://misko.hevery.com/2008/12/15/static-methods-are-death-to-testability/feed/" rel="self" type="application/rss+xml" />
	<link>http://misko.hevery.com/2008/12/15/static-methods-are-death-to-testability/</link>
	<description>Testability Explorer</description>
	<lastBuildDate>Tue, 09 Mar 2010 04:29:26 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: misko</title>
		<link>http://misko.hevery.com/2008/12/15/static-methods-are-death-to-testability/comment-page-1/#comment-3180</link>
		<dc:creator>misko</dc:creator>
		<pubDate>Tue, 09 Mar 2010 04:29:26 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=352#comment-3180</guid>
		<description>Hi Monoj,

My understanding of encapsulation is that only the object methods should interact with the state of the object. This is why a service object which has getters/setters breaks encapsulation. With regard to constructor I don&#039;t think it break encapsulation, as you are not allowed to modify the state of the object, you only need to provide the state/dependencies on creation. In addition the callee is does not know how to create the dependency, it asks for it likewise. 

Here is some more discussion I found online
http://stackoverflow.com/questions/1005473/must-dependency-injection-come-at-the-expense-of-encapsulation</description>
		<content:encoded><![CDATA[<p>Hi Monoj,</p>
<p>My understanding of encapsulation is that only the object methods should interact with the state of the object. This is why a service object which has getters/setters breaks encapsulation. With regard to constructor I don&#8217;t think it break encapsulation, as you are not allowed to modify the state of the object, you only need to provide the state/dependencies on creation. In addition the callee is does not know how to create the dependency, it asks for it likewise. </p>
<p>Here is some more discussion I found online<br />
<a href="http://stackoverflow.com/questions/1005473/must-dependency-injection-come-at-the-expense-of-encapsulation" rel="nofollow">http://stackoverflow.com/questions/1005473/must-dependency-injection-come-at-the-expense-of-encapsulation</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: manoj</title>
		<link>http://misko.hevery.com/2008/12/15/static-methods-are-death-to-testability/comment-page-1/#comment-3175</link>
		<dc:creator>manoj</dc:creator>
		<pubDate>Mon, 08 Mar 2010 11:41:42 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=352#comment-3175</guid>
		<description>Hi,
with regards to this and also the article about Singletons, it seems to me that you are talking in general about code that has dependecy pull. e.g.
a Class X has a process() method that goes like {
     y = new YImpl();
     y.doIt();
}
So you have a problem with testing this method since calling process() is always calling YImpl, and this cannot be changed with some other implementation. So YImpl should have been explicitly passed to process() ?

But as we pass more and more parameters, does it not break encapsulation ? There could be problems related with improper use. So somebody may be able to pass an incorrect instance of creditcardprocessor that bypasses logging/auth ?</description>
		<content:encoded><![CDATA[<p>Hi,<br />
with regards to this and also the article about Singletons, it seems to me that you are talking in general about code that has dependecy pull. e.g.<br />
a Class X has a process() method that goes like {<br />
     y = new YImpl();<br />
     y.doIt();<br />
}<br />
So you have a problem with testing this method since calling process() is always calling YImpl, and this cannot be changed with some other implementation. So YImpl should have been explicitly passed to process() ?</p>
<p>But as we pass more and more parameters, does it not break encapsulation ? There could be problems related with improper use. So somebody may be able to pass an incorrect instance of creditcardprocessor that bypasses logging/auth ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: misko</title>
		<link>http://misko.hevery.com/2008/12/15/static-methods-are-death-to-testability/comment-page-1/#comment-2720</link>
		<dc:creator>misko</dc:creator>
		<pubDate>Sat, 02 Jan 2010 20:52:26 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=352#comment-2720</guid>
		<description>The performance of using static vs instance method/variables is next to insignificant, so I would not use that as an argument. :-)</description>
		<content:encoded><![CDATA[<p>The performance of using static vs instance method/variables is next to insignificant, so I would not use that as an argument. <img src='http://misko.hevery.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Helltime for January 1 &#171; I Built His Cage</title>
		<link>http://misko.hevery.com/2008/12/15/static-methods-are-death-to-testability/comment-page-1/#comment-2712</link>
		<dc:creator>Helltime for January 1 &#171; I Built His Cage</dc:creator>
		<pubDate>Sat, 02 Jan 2010 01:34:53 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=352#comment-2712</guid>
		<description>[...] The gist of the post is to use static members whenever you can for values that you know won&#8217;t change. There is a potentially significant performance boost, but I fear advice like this will lead monkeys to apply staticity to areas where it is inappropriate and doom their testing efforts. [...]</description>
		<content:encoded><![CDATA[<p>[...] The gist of the post is to use static members whenever you can for values that you know won&#8217;t change. There is a potentially significant performance boost, but I fear advice like this will lead monkeys to apply staticity to areas where it is inappropriate and doom their testing efforts. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Se hace camino al andar&#8230; &#187; Blog Archive &#187; Métodos estáticos y pruebas unitarias</title>
		<link>http://misko.hevery.com/2008/12/15/static-methods-are-death-to-testability/comment-page-1/#comment-2585</link>
		<dc:creator>Se hace camino al andar&#8230; &#187; Blog Archive &#187; Métodos estáticos y pruebas unitarias</dc:creator>
		<pubDate>Sun, 13 Dec 2009 22:54:20 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=352#comment-2585</guid>
		<description>[...] para obtener información de contexto y, sobre todo, de la plataforma. Y me viene al pelo el reciente artículo de Misko Hevery donde explica por qué los métodos estáticos son tan malos para las pruebas y delatan diseños [...]</description>
		<content:encoded><![CDATA[<p>[...] para obtener información de contexto y, sobre todo, de la plataforma. Y me viene al pelo el reciente artículo de Misko Hevery donde explica por qué los métodos estáticos son tan malos para las pruebas y delatan diseños [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Principles, Patterns, and Practices of Mediocre Programming : Steve Smith's Blog</title>
		<link>http://misko.hevery.com/2008/12/15/static-methods-are-death-to-testability/comment-page-1/#comment-2045</link>
		<dc:creator>Principles, Patterns, and Practices of Mediocre Programming : Steve Smith's Blog</dc:creator>
		<pubDate>Thu, 08 Oct 2009 18:44:01 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=352#comment-2045</guid>
		<description>[...] Static Methods are Death to Testability [...]</description>
		<content:encoded><![CDATA[<p>[...] Static Methods are Death to Testability [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: misko</title>
		<link>http://misko.hevery.com/2008/12/15/static-methods-are-death-to-testability/comment-page-1/#comment-1804</link>
		<dc:creator>misko</dc:creator>
		<pubDate>Wed, 02 Sep 2009 15:43:20 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=352#comment-1804</guid>
		<description>@Heiko,

I know few functional languages, and while I am nowhere as versed in them nor have as much experience in OO, I do know, that many things are still the same. Instead of injecting classes you need to inject functions, and testability is still something you need to think about.

But these blog posts are not about functional languages! These blog posts are about OO languages. 

-- Misko</description>
		<content:encoded><![CDATA[<p>@Heiko,</p>
<p>I know few functional languages, and while I am nowhere as versed in them nor have as much experience in OO, I do know, that many things are still the same. Instead of injecting classes you need to inject functions, and testability is still something you need to think about.</p>
<p>But these blog posts are not about functional languages! These blog posts are about OO languages. </p>
<p>&#8211; Misko</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Heiko</title>
		<link>http://misko.hevery.com/2008/12/15/static-methods-are-death-to-testability/comment-page-1/#comment-1803</link>
		<dc:creator>Heiko</dc:creator>
		<pubDate>Wed, 02 Sep 2009 14:49:56 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=352#comment-1803</guid>
		<description>Learn a functional language. Then you certainly will rewrite your post.</description>
		<content:encoded><![CDATA[<p>Learn a functional language. Then you certainly will rewrite your post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: misko</title>
		<link>http://misko.hevery.com/2008/12/15/static-methods-are-death-to-testability/comment-page-1/#comment-1595</link>
		<dc:creator>misko</dc:creator>
		<pubDate>Tue, 11 Aug 2009 15:21:58 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=352#comment-1595</guid>
		<description>@Mr Panda,

I am totally serious! The thing is that Math.abs() is easy to test and it is static, but it is also a leaf of your call graph, and should really be -5.abs() anyway. It is easy to test, but not because it is static, but because it is leaf. The farther your static method is from the leaf of the call graph the harder it will be to test. Look at main method, it is essentially impossible to test anything form it, and it is static. Static methods cannot be overridden, and there lies the problem. Just because some static methods are easy to test does not imply that all static methods are easy to test.</description>
		<content:encoded><![CDATA[<p>@Mr Panda,</p>
<p>I am totally serious! The thing is that Math.abs() is easy to test and it is static, but it is also a leaf of your call graph, and should really be -5.abs() anyway. It is easy to test, but not because it is static, but because it is leaf. The farther your static method is from the leaf of the call graph the harder it will be to test. Look at main method, it is essentially impossible to test anything form it, and it is static. Static methods cannot be overridden, and there lies the problem. Just because some static methods are easy to test does not imply that all static methods are easy to test.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mr Panda</title>
		<link>http://misko.hevery.com/2008/12/15/static-methods-are-death-to-testability/comment-page-1/#comment-1590</link>
		<dc:creator>Mr Panda</dc:creator>
		<pubDate>Tue, 11 Aug 2009 11:16:47 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=352#comment-1590</guid>
		<description>To the author: you can&#039;t be serious. Free functions are probably the most unit-testable constructs there are.

(Presuming they&#039;re side effect free - and only a lunatic would routinely write free-functions that modify global state).</description>
		<content:encoded><![CDATA[<p>To the author: you can&#8217;t be serious. Free functions are probably the most unit-testable constructs there are.</p>
<p>(Presuming they&#8217;re side effect free &#8211; and only a lunatic would routinely write free-functions that modify global state).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
