<?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: Debug.Assert Considered Pointless</title>
	<atom:link href="http://www.hackification.com/2009/06/10/debug-assert-considered-pointless/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hackification.com/2009/06/10/debug-assert-considered-pointless/</link>
	<description></description>
	<lastBuildDate>Fri, 23 Jul 2010 14:53:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Joe</title>
		<link>http://www.hackification.com/2009/06/10/debug-assert-considered-pointless/comment-page-1/#comment-391</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Sun, 13 Sep 2009 17:25:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackification.com/?p=214#comment-391</guid>
		<description>FFS... I came across this evening running a webservice in debug mode from another VS instance - they aren&#039;t evaluated even though they step through.  I can&#039;t believe that there is no way to enable these checks, especially when they are effectively validation statements in there own right!!  Now I&#039;ve got to rewrite all of them as I want validation checks!  Pathetic as it disrupts code behaviour and gives you a different flow of execution!</description>
		<content:encoded><![CDATA[<p>FFS&#8230; I came across this evening running a webservice in debug mode from another VS instance &#8211; they aren&#8217;t evaluated even though they step through.  I can&#8217;t believe that there is no way to enable these checks, especially when they are effectively validation statements in there own right!!  Now I&#8217;ve got to rewrite all of them as I want validation checks!  Pathetic as it disrupts code behaviour and gives you a different flow of execution!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stusmith</title>
		<link>http://www.hackification.com/2009/06/10/debug-assert-considered-pointless/comment-page-1/#comment-390</link>
		<dc:creator>stusmith</dc:creator>
		<pubDate>Thu, 11 Jun 2009 17:04:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackification.com/?p=214#comment-390</guid>
		<description>Dion: In the example you give, I think the assertion should be stronger: it should throw an exception in both debug and release. If it&#039;s invalid in debug, it should be invalid in release too.

Too many asserts... yes a bad thing. Qualified: so long as they are replaced with something else. And, of course, &quot;too many&quot; is of course a value judgement.</description>
		<content:encoded><![CDATA[<p>Dion: In the example you give, I think the assertion should be stronger: it should throw an exception in both debug and release. If it&#8217;s invalid in debug, it should be invalid in release too.</p>
<p>Too many asserts&#8230; yes a bad thing. Qualified: so long as they are replaced with something else. And, of course, &#8220;too many&#8221; is of course a value judgement.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dion</title>
		<link>http://www.hackification.com/2009/06/10/debug-assert-considered-pointless/comment-page-1/#comment-389</link>
		<dc:creator>Dion</dc:creator>
		<pubDate>Thu, 11 Jun 2009 16:22:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackification.com/?p=214#comment-389</guid>
		<description>Regarding Excel, you read that in &quot;Debugging the Development Process&quot; by Steve Maguire.

Point 1 is like overcommenting.  It seems like an assert here is not needed, as would be a comment like &quot;#do something with bar&quot;.

I find asserts useful for
a) Documenting assumptions and preconditions.  For example, you could add an assert to show that you never expect to get a NULL.  Otherwise, two years from now, someone is going to wonder whether ignoring NULL was on purpose or a bug.
b) Helping develop new code.  For example, if loop over a list for an item that I know is in it, I might add an assert to make sure my index was within the bounds:

for (i = 0; wanted != items[i]; i++) {};
assert(i &lt;= numberOf(items)); # wanted must be in my array of items, right?

Then the question becomes whether that assert should ever be removed.

Would you say that too many asserts is a bad thing?</description>
		<content:encoded><![CDATA[<p>Regarding Excel, you read that in &#8220;Debugging the Development Process&#8221; by Steve Maguire.</p>
<p>Point 1 is like overcommenting.  It seems like an assert here is not needed, as would be a comment like &#8220;#do something with bar&#8221;.</p>
<p>I find asserts useful for<br />
a) Documenting assumptions and preconditions.  For example, you could add an assert to show that you never expect to get a NULL.  Otherwise, two years from now, someone is going to wonder whether ignoring NULL was on purpose or a bug.<br />
b) Helping develop new code.  For example, if loop over a list for an item that I know is in it, I might add an assert to make sure my index was within the bounds:</p>
<p>for (i = 0; wanted != items[i]; i++) {};<br />
assert(i &lt;= numberOf(items)); # wanted must be in my array of items, right?</p>
<p>Then the question becomes whether that assert should ever be removed.</p>
<p>Would you say that too many asserts is a bad thing?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alejo</title>
		<link>http://www.hackification.com/2009/06/10/debug-assert-considered-pointless/comment-page-1/#comment-388</link>
		<dc:creator>Alejo</dc:creator>
		<pubDate>Wed, 10 Jun 2009 23:51:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackification.com/?p=214#comment-388</guid>
		<description>Interesting. :-)

I wrote a whole section about assertion checks in my Principles of Software article, http://wiki.freaks-unidos.net/weblogs/azul/principles-of-software#assertion-checks.  I agree with most of the points you raise, indeed I said: “You should only disable your assertion checks if it is strictly necessary (for example, for performance reasons). I almost always run my software with assertion checks enabled.”  I also wrote some thoughts about how slow it is acceptable to make your checks.

I&#039;ll probably add a link to this article in that section.  I&#039;ll probably update it a bit to mention some of the ideas that you have here (I like the idea of a config switch that can enable or disable expensive tests).

One small suggestion: if one only skims through your article, it would at first seem to recommend that programmers don&#039;t explicitly validate the state of their processes to protect against invalid programs.  However, I think that couldn&#039;t be further from your point: your point is actually that they should check it with better, “stronger” (so to say), mechanisms that Debug.assert.  Perhaps you should rephrase the starting paragraph to say that you think that validating the state of your program is too important a task to use Debug.assert.</description>
		<content:encoded><![CDATA[<p>Interesting. <img src='http://www.hackification.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I wrote a whole section about assertion checks in my Principles of Software article, <a href="http://wiki.freaks-unidos.net/weblogs/azul/principles-of-software#assertion-checks" rel="nofollow">http://wiki.freaks-unidos.net/weblogs/azul/principles-of-software#assertion-checks</a>.  I agree with most of the points you raise, indeed I said: “You should only disable your assertion checks if it is strictly necessary (for example, for performance reasons). I almost always run my software with assertion checks enabled.”  I also wrote some thoughts about how slow it is acceptable to make your checks.</p>
<p>I&#8217;ll probably add a link to this article in that section.  I&#8217;ll probably update it a bit to mention some of the ideas that you have here (I like the idea of a config switch that can enable or disable expensive tests).</p>
<p>One small suggestion: if one only skims through your article, it would at first seem to recommend that programmers don&#8217;t explicitly validate the state of their processes to protect against invalid programs.  However, I think that couldn&#8217;t be further from your point: your point is actually that they should check it with better, “stronger” (so to say), mechanisms that Debug.assert.  Perhaps you should rephrase the starting paragraph to say that you think that validating the state of your program is too important a task to use Debug.assert.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BillAtHRST</title>
		<link>http://www.hackification.com/2009/06/10/debug-assert-considered-pointless/comment-page-1/#comment-387</link>
		<dc:creator>BillAtHRST</dc:creator>
		<pubDate>Wed, 10 Jun 2009 23:32:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackification.com/?p=214#comment-387</guid>
		<description>If you&#039;re already handling exceptions (as you must in .Net, for instance) then throwing an exception may be the proper thing to do.

But there&#039;s still a lot of C and C++ code out there that does not throw exceptions.  In my co&#039;s case, we had a library product where we wanted to avoid forcing users to use exception handling -- at least at the time, a lot of people (rightly or wrongly) felt strongly about potential overhead, etc.

There are also times you want to be able to perform addl checks that are simply too expensive for a release build -- for example, google on _GLIBCXX_DEBUG use with gcc.

Short version is that assertions can be very valuable, but should not be the only (or even the first) line of defense against bugs.</description>
		<content:encoded><![CDATA[<p>If you&#8217;re already handling exceptions (as you must in .Net, for instance) then throwing an exception may be the proper thing to do.</p>
<p>But there&#8217;s still a lot of C and C++ code out there that does not throw exceptions.  In my co&#8217;s case, we had a library product where we wanted to avoid forcing users to use exception handling &#8212; at least at the time, a lot of people (rightly or wrongly) felt strongly about potential overhead, etc.</p>
<p>There are also times you want to be able to perform addl checks that are simply too expensive for a release build &#8212; for example, google on _GLIBCXX_DEBUG use with gcc.</p>
<p>Short version is that assertions can be very valuable, but should not be the only (or even the first) line of defense against bugs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Donald Ray Moore Jr. (mindrape)</title>
		<link>http://www.hackification.com/2009/06/10/debug-assert-considered-pointless/comment-page-1/#comment-386</link>
		<dc:creator>Donald Ray Moore Jr. (mindrape)</dc:creator>
		<pubDate>Wed, 10 Jun 2009 21:35:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackification.com/?p=214#comment-386</guid>
		<description>or defer validation at it&#039;s destination (e.g. database).</description>
		<content:encoded><![CDATA[<p>or defer validation at it&#8217;s destination (e.g. database).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
