<?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: To Assert or Not To Assert</title>
	<atom:link href="http://misko.hevery.com/2009/02/09/to-assert-or-not-to-assert/feed/" rel="self" type="application/rss+xml" />
	<link>http://misko.hevery.com/2009/02/09/to-assert-or-not-to-assert/</link>
	<description>Testability Explorer</description>
	<lastBuildDate>Thu, 02 Sep 2010 04:05:01 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Can you spot Java Puzzler in this snippet? at JAW Speak</title>
		<link>http://misko.hevery.com/2009/02/09/to-assert-or-not-to-assert/comment-page-1/#comment-1965</link>
		<dc:creator>Can you spot Java Puzzler in this snippet? at JAW Speak</dc:creator>
		<pubDate>Wed, 30 Sep 2009 20:00:10 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=374#comment-1965</guid>
		<description>[...] and I saw this in a test with a particularly ugly constructor with 12 parameters. We were following Misko&#8217;s style of &#8220;use nulls in tests, but not in production code&#8221; and thus that Boolean [...]</description>
		<content:encoded><![CDATA[<p>[...] and I saw this in a test with a particularly ugly constructor with 12 parameters. We were following Misko&#8217;s style of &#8220;use nulls in tests, but not in production code&#8221; and thus that Boolean [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Should we enforce constructor args?! &#171; Journal of a software dev</title>
		<link>http://misko.hevery.com/2009/02/09/to-assert-or-not-to-assert/comment-page-1/#comment-1275</link>
		<dc:creator>Should we enforce constructor args?! &#171; Journal of a software dev</dc:creator>
		<pubDate>Sat, 27 Jun 2009 10:54:07 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=374#comment-1275</guid>
		<description>[...] written and the information surrounding good OO and unit testing was, anyhow I came across this post which made me think about whether we should be asserting the collabarators in the constructor or [...]</description>
		<content:encoded><![CDATA[<p>[...] written and the information surrounding good OO and unit testing was, anyhow I came across this post which made me think about whether we should be asserting the collabarators in the constructor or [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Giorgio Sironi</title>
		<link>http://misko.hevery.com/2009/02/09/to-assert-or-not-to-assert/comment-page-1/#comment-1145</link>
		<dc:creator>Giorgio Sironi</dc:creator>
		<pubDate>Sat, 30 May 2009 09:23:42 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=374#comment-1145</guid>
		<description>You say you can write a test for the factory that will asserts that non-null values are passed to the constructor. But how can you write such a test? I know Guice will take care of, but the contract of my factories is &#039;you call create*(), I return an object&#039;. The object collaborators are private field references and I cannot access them to see if they are null. Maybe a method verifyNull() on the created object can do the work, but to me it seems ugly.</description>
		<content:encoded><![CDATA[<p>You say you can write a test for the factory that will asserts that non-null values are passed to the constructor. But how can you write such a test? I know Guice will take care of, but the contract of my factories is &#8216;you call create*(), I return an object&#8217;. The object collaborators are private field references and I cannot access them to see if they are null. Maybe a method verifyNull() on the created object can do the work, but to me it seems ugly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig McDonnell</title>
		<link>http://misko.hevery.com/2009/02/09/to-assert-or-not-to-assert/comment-page-1/#comment-739</link>
		<dc:creator>Craig McDonnell</dc:creator>
		<pubDate>Thu, 05 Mar 2009 23:04:24 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=374#comment-739</guid>
		<description>From experience, defensive programming has helped me avoid long debugging sessions on many occassions. I&#039;m not sure I can agree with this post but it&#039;s certainly food for thought.
I&#039;ve been considering using the Findbugs annotations and perhaps the @NonNull annotation could be of use here.
With this annotation we can enforce the null check for client code under /src but not /test? -This could even have the added benefit of moving the constraint check from run-time to compile-time.</description>
		<content:encoded><![CDATA[<p>From experience, defensive programming has helped me avoid long debugging sessions on many occassions. I&#8217;m not sure I can agree with this post but it&#8217;s certainly food for thought.<br />
I&#8217;ve been considering using the Findbugs annotations and perhaps the @NonNull annotation could be of use here.<br />
With this annotation we can enforce the null check for client code under /src but not /test? -This could even have the added benefit of moving the constraint check from run-time to compile-time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mgira</title>
		<link>http://misko.hevery.com/2009/02/09/to-assert-or-not-to-assert/comment-page-1/#comment-733</link>
		<dc:creator>mgira</dc:creator>
		<pubDate>Wed, 04 Mar 2009 10:17:42 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=374#comment-733</guid>
		<description>Hi Miško,first, let me say that i really enjoy reading your blog!Back to topic:If you want to test Objects in an &quot;inconsistent&quot; state (i.e. not completely initialized), maybe setter injection would be a more flexible approach.</description>
		<content:encoded><![CDATA[<p>Hi Miško,first, let me say that i really enjoy reading your blog!Back to topic:If you want to test Objects in an &#8220;inconsistent&#8221; state (i.e. not completely initialized), maybe setter injection would be a more flexible approach.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Martin</title>
		<link>http://misko.hevery.com/2009/02/09/to-assert-or-not-to-assert/comment-page-1/#comment-716</link>
		<dc:creator>Chris Martin</dc:creator>
		<pubDate>Sat, 21 Feb 2009 07:49:13 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=374#comment-716</guid>
		<description>Because, I never want my entities in an invalid state, I&#039;d prefer to keep the asserts in place and use a simple Object Mother (provide default stubs/mocks), if not a full on IoC, for testing.</description>
		<content:encoded><![CDATA[<p>Because, I never want my entities in an invalid state, I&#8217;d prefer to keep the asserts in place and use a simple Object Mother (provide default stubs/mocks), if not a full on IoC, for testing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee Campbell</title>
		<link>http://misko.hevery.com/2009/02/09/to-assert-or-not-to-assert/comment-page-1/#comment-691</link>
		<dc:creator>Lee Campbell</dc:creator>
		<pubDate>Tue, 17 Feb 2009 10:47:48 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=374#comment-691</guid>
		<description>Love the blog, and like other disagree with you on this case. If the class was dependant on abstractions and not concrete classes then testing would not be a problem. You could have the asserts and in your tests just use null objects or a mocking framework.</description>
		<content:encoded><![CDATA[<p>Love the blog, and like other disagree with you on this case. If the class was dependant on abstractions and not concrete classes then testing would not be a problem. You could have the asserts and in your tests just use null objects or a mocking framework.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jose M Beas</title>
		<link>http://misko.hevery.com/2009/02/09/to-assert-or-not-to-assert/comment-page-1/#comment-688</link>
		<dc:creator>Jose M Beas</dc:creator>
		<pubDate>Mon, 16 Feb 2009 01:35:53 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=374#comment-688</guid>
		<description>Dear Mi&lt;a href=&quot;../../../../2008/09/30/about/&quot; rel=&quot;nofollow&quot;&gt;š&lt;/a&gt;ko,Although I always agree with your opinions, I&#039;m afraid I cannot be with you in this case. I also think that your example is wrong because (IMHO) if you can call the constructor with nulls or even NullObjects, that smells to those collaborations are optional, so you can simply take them away from the constructor and put setters for them (or use the Builder pattern). In both cases you can keep the asserts for those properties that never can be null. Actually you should move them to the setters (or builder methods).And also I&#039;m not sure what you mean when saying (in one of the comments you made later) that &quot;it is not the responsibility of the class to worry about its construction&quot;. You mean, in a dependency injection container context, that it is the container&#039;s factory responsibility to create the objects? But how can this creation strategy affect to the assertion of non-null arguments in the constructor of a class?Best regards,JMB&lt;a href=&quot;../../../../2008/09/30/about/&quot; rel=&quot;nofollow&quot;&gt;&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Dear Mi<a href="../../../../2008/09/30/about/" rel="nofollow">š</a>ko,Although I always agree with your opinions, I&#8217;m afraid I cannot be with you in this case. I also think that your example is wrong because (IMHO) if you can call the constructor with nulls or even NullObjects, that smells to those collaborations are optional, so you can simply take them away from the constructor and put setters for them (or use the Builder pattern). In both cases you can keep the asserts for those properties that never can be null. Actually you should move them to the setters (or builder methods).And also I&#8217;m not sure what you mean when saying (in one of the comments you made later) that &#8220;it is not the responsibility of the class to worry about its construction&#8221;. You mean, in a dependency injection container context, that it is the container&#8217;s factory responsibility to create the objects? But how can this creation strategy affect to the assertion of non-null arguments in the constructor of a class?Best regards,JMB<a href="../../../../2008/09/30/about/" rel="nofollow"></a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pat Maddox</title>
		<link>http://misko.hevery.com/2009/02/09/to-assert-or-not-to-assert/comment-page-1/#comment-684</link>
		<dc:creator>Pat Maddox</dc:creator>
		<pubDate>Fri, 13 Feb 2009 18:04:47 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=374#comment-684</guid>
		<description>I think it would make a lot more sense to leave the constructir asserts in place, and use mock objects or a test data builder to simplify the tests.</description>
		<content:encoded><![CDATA[<p>I think it would make a lot more sense to leave the constructir asserts in place, and use mock objects or a test data builder to simplify the tests.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adil Aijaz</title>
		<link>http://misko.hevery.com/2009/02/09/to-assert-or-not-to-assert/comment-page-1/#comment-681</link>
		<dc:creator>Adil Aijaz</dc:creator>
		<pubDate>Fri, 13 Feb 2009 07:33:59 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=374#comment-681</guid>
		<description>argh .. the pseudocode got messed up</description>
		<content:encoded><![CDATA[<p>argh .. the pseudocode got messed up</p>
]]></content:encoded>
	</item>
</channel>
</rss>
