<?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://msinilo.pl/blog/?feed=rss2&#038;p=544" rel="self" type="application/rss+xml" />
	<link>http://msinilo.pl/blog/?p=544</link>
	<description>Random gamedev ramblings</description>
	<lastBuildDate>Sun, 05 Sep 2010 06:59:46 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: admin</title>
		<link>http://msinilo.pl/blog/?p=544&#038;cpage=1#comment-20925</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Sat, 15 May 2010 19:58:07 +0000</pubDate>
		<guid isPermaLink="false">http://msinilo.pl/blog/?p=544#comment-20925</guid>
		<description>Pavel: Not really. It&#039;s not even about the performance, they&#039;re simply not always fully supported on some platforms.</description>
		<content:encoded><![CDATA[<p>Pavel: Not really. It&#8217;s not even about the performance, they&#8217;re simply not always fully supported on some platforms.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pavel Shevaev</title>
		<link>http://msinilo.pl/blog/?p=544&#038;cpage=1#comment-20907</link>
		<dc:creator>Pavel Shevaev</dc:creator>
		<pubDate>Sat, 15 May 2010 07:35:12 +0000</pubDate>
		<guid isPermaLink="false">http://msinilo.pl/blog/?p=544#comment-20907</guid>
		<description>... and it looks like using exceptions for errors which should not be asserted is not an option in gamedev, right ? ;)</description>
		<content:encoded><![CDATA[<p>&#8230; and it looks like using exceptions for errors which should not be asserted is not an option in gamedev, right ? ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mateusz Loskot</title>
		<link>http://msinilo.pl/blog/?p=544&#038;cpage=1#comment-19257</link>
		<dc:creator>Mateusz Loskot</dc:creator>
		<pubDate>Wed, 03 Feb 2010 12:08:45 +0000</pubDate>
		<guid isPermaLink="false">http://msinilo.pl/blog/?p=544#comment-19257</guid>
		<description>@Liam Regarding assertions in TDD. This comment lacks of details about context to judge use of assertions this way as a good or bad practice. I&#039;m not saying I don&#039;t agree with Fowler. Though, it&#039;s nothing wrong to decide to use assertions as checkpoints in test cases. I don&#039;t discuss if it is convenient or not, but from testing point of view, they fit it well - assertion checks if assumed condition is fulfilled or not.</description>
		<content:encoded><![CDATA[<p>@Liam Regarding assertions in TDD. This comment lacks of details about context to judge use of assertions this way as a good or bad practice. I&#8217;m not saying I don&#8217;t agree with Fowler. Though, it&#8217;s nothing wrong to decide to use assertions as checkpoints in test cases. I don&#8217;t discuss if it is convenient or not, but from testing point of view, they fit it well &#8211; assertion checks if assumed condition is fulfilled or not.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://msinilo.pl/blog/?p=544&#038;cpage=1#comment-18977</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Sun, 10 Jan 2010 12:46:58 +0000</pubDate>
		<guid isPermaLink="false">http://msinilo.pl/blog/?p=544#comment-18977</guid>
		<description>OK, I see. I think we&#039;re talking about same stuff, roughly. I mentioned separating error handling from asserts. Asserts are like last resort option that triggers if higher-level code didn&#039;t deal with invalid input (like invalid index for example). With automated test system &amp; automated error reporting (so that artists don&#039;t have to run to you every time it crashes) it&#039;s less painful than it may sound.
One problem I see with being too tolerant for data errors is that you end up with code filled with if (this) or if (that) that&#039;s only needed during development (and probably shouldn&#039;t be needed atl all with a little bit of effort and better tools). 
Whole matter should also probably be treated in a little bit different way in tools &amp; in game. Tools should be much more forgiving, I agree. </description>
		<content:encoded><![CDATA[<p>OK, I see. I think we&#8217;re talking about same stuff, roughly. I mentioned separating error handling from asserts. Asserts are like last resort option that triggers if higher-level code didn&#8217;t deal with invalid input (like invalid index for example). With automated test system &#038; automated error reporting (so that artists don&#8217;t have to run to you every time it crashes) it&#8217;s less painful than it may sound.<br />
One problem I see with being too tolerant for data errors is that you end up with code filled with if (this) or if (that) that&#8217;s only needed during development (and probably shouldn&#8217;t be needed atl all with a little bit of effort and better tools).<br />
Whole matter should also probably be treated in a little bit different way in tools &#038; in game. Tools should be much more forgiving, I agree.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ed</title>
		<link>http://msinilo.pl/blog/?p=544&#038;cpage=1#comment-18970</link>
		<dc:creator>ed</dc:creator>
		<pubDate>Sun, 10 Jan 2010 02:04:47 +0000</pubDate>
		<guid isPermaLink="false">http://msinilo.pl/blog/?p=544#comment-18970</guid>
		<description>My guess is that you didn&#039;t get my point :)
There are only two kinds of problems: those you foresee and those you don&#039;t. Those you foresee are always &quot;marked&quot; with assert. If you place an assert in []operator then it means that you actually foresee a potential problem here: &quot;index out bound = bad&quot;. 
Placing an exit() means &quot;I don&#039;t have time know, and I&#039;ll deal with it when it happens&quot;. And that is actually &quot;sweeping under a rug&quot; because this will never save your time. You will eventually spend that extra time to fix the problem. Question is why anyone besides you must waste his time ?

My point is: if program closes, I don&#039;t care if that was SIGSEGV crash or an assert with message &quot;Doh!&quot;. This is always the worst thing may happen to user. You will loose lots of time (even 5min of work), you will waste your time on start/loading again and you will waste time waiting till problem gets fixed. That sumes up to a lot of wasted time.

You want feedback then track problems often. Database (as you mentioned), instant messaging, anything is ok. Placing exit() will not improve feedback. People (and I mean artists :) ) usually will get tool/game crashed 50 times before they&#039;ll start whining about it. And running to a programmer, every time program crashes is another waste of time.

So, never let the tool/game crash. Check the list of the known issues often, and be user friendly.

About [] operator. In general solution, sure, you may return static variable (protect against read/write) but it would be much better if you place an assert before you use [] operator. There aren&#039;t many places with [] usage. You can always place an assert at function entry. It will be easier for you to decide what to do if &quot;index &gt; size()&quot; and skip plenty of code.

Yes, assert is &quot;just&quot; error handling (during a production time). But definitely it shouldn&#039;t be yet another fancy way to crash a program.</description>
		<content:encoded><![CDATA[<p>My guess is that you didn&#8217;t get my point :)<br />
There are only two kinds of problems: those you foresee and those you don&#8217;t. Those you foresee are always &#8220;marked&#8221; with assert. If you place an assert in []operator then it means that you actually foresee a potential problem here: &#8220;index out bound = bad&#8221;.<br />
Placing an exit() means &#8220;I don&#8217;t have time know, and I&#8217;ll deal with it when it happens&#8221;. And that is actually &#8220;sweeping under a rug&#8221; because this will never save your time. You will eventually spend that extra time to fix the problem. Question is why anyone besides you must waste his time ?</p>
<p>My point is: if program closes, I don&#8217;t care if that was SIGSEGV crash or an assert with message &#8220;Doh!&#8221;. This is always the worst thing may happen to user. You will loose lots of time (even 5min of work), you will waste your time on start/loading again and you will waste time waiting till problem gets fixed. That sumes up to a lot of wasted time.</p>
<p>You want feedback then track problems often. Database (as you mentioned), instant messaging, anything is ok. Placing exit() will not improve feedback. People (and I mean artists :) ) usually will get tool/game crashed 50 times before they&#8217;ll start whining about it. And running to a programmer, every time program crashes is another waste of time.</p>
<p>So, never let the tool/game crash. Check the list of the known issues often, and be user friendly.</p>
<p>About [] operator. In general solution, sure, you may return static variable (protect against read/write) but it would be much better if you place an assert before you use [] operator. There aren&#8217;t many places with [] usage. You can always place an assert at function entry. It will be easier for you to decide what to do if &#8220;index &gt; size()&#8221; and skip plenty of code.</p>
<p>Yes, assert is &#8220;just&#8221; error handling (during a production time). But definitely it shouldn&#8217;t be yet another fancy way to crash a program.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maciej Miasik</title>
		<link>http://msinilo.pl/blog/?p=544&#038;cpage=1#comment-18962</link>
		<dc:creator>Maciej Miasik</dc:creator>
		<pubDate>Sat, 09 Jan 2010 18:17:22 +0000</pubDate>
		<guid isPermaLink="false">http://msinilo.pl/blog/?p=544#comment-18962</guid>
		<description>Well, if there&#039;s an alternative route/solution for the assert condition it only means that this isn&#039;t something assert are for. This is just error handling. 

Also, such approach diminishes feedback - instead of fixing the problem, it is only swept under a rug only to resurface later and/or elsewhere. It&#039;s very difficult to judge any productivity gains from extended assert handling to those delayed loses which are result from using improper data or alternative solutions.

Anyone who loses 2-3 hours of work due to tool assert/crash should be educated how to use unstable, WIP tools first. Save often. Backup you work. Be prepared.

More frequently the problems that are indicated by asserts are fixed the better for end user.</description>
		<content:encoded><![CDATA[<p>Well, if there&#8217;s an alternative route/solution for the assert condition it only means that this isn&#8217;t something assert are for. This is just error handling. </p>
<p>Also, such approach diminishes feedback &#8211; instead of fixing the problem, it is only swept under a rug only to resurface later and/or elsewhere. It&#8217;s very difficult to judge any productivity gains from extended assert handling to those delayed loses which are result from using improper data or alternative solutions.</p>
<p>Anyone who loses 2-3 hours of work due to tool assert/crash should be educated how to use unstable, WIP tools first. Save often. Backup you work. Be prepared.</p>
<p>More frequently the problems that are indicated by asserts are fixed the better for end user.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://msinilo.pl/blog/?p=544&#038;cpage=1#comment-18961</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Sat, 09 Jan 2010 16:52:34 +0000</pubDate>
		<guid isPermaLink="false">http://msinilo.pl/blog/?p=544#comment-18961</guid>
		<description>I&#039;m not convinced. I mean, if you foresee a problem, it&#039;s not a place for assert. Asserts are for conditions that have to be satisfied in order for the program to work correctly. Once assertion fails, all bets are off. How would you suggest dealing with out of range indices in [] operator? Returning dummy values? What to do when we&#039;re writing to array? 
Asserts crashing tool/game can be a problem, but in my experience - not that critical. I worked in studios that used skippable asserts (or no asserts in release builds), worked in those that had asserts terminating the game (teams of 100+, not 1-2 programmers :), the latter seemed to work better (in my opinion). But yeah, that&#039;s one of the things I&#039;m not entirely sure about, just a hunch.</description>
		<content:encoded><![CDATA[<p>I&#8217;m not convinced. I mean, if you foresee a problem, it&#8217;s not a place for assert. Asserts are for conditions that have to be satisfied in order for the program to work correctly. Once assertion fails, all bets are off. How would you suggest dealing with out of range indices in [] operator? Returning dummy values? What to do when we&#8217;re writing to array?<br />
Asserts crashing tool/game can be a problem, but in my experience &#8211; not that critical. I worked in studios that used skippable asserts (or no asserts in release builds), worked in those that had asserts terminating the game (teams of 100+, not 1-2 programmers :), the latter seemed to work better (in my opinion). But yeah, that&#8217;s one of the things I&#8217;m not entirely sure about, just a hunch.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ed</title>
		<link>http://msinilo.pl/blog/?p=544&#038;cpage=1#comment-18958</link>
		<dc:creator>ed</dc:creator>
		<pubDate>Sat, 09 Jan 2010 14:09:58 +0000</pubDate>
		<guid isPermaLink="false">http://msinilo.pl/blog/?p=544#comment-18958</guid>
		<description>I disagree that assert should stop execution. If a programmer foresees a problem in a particular place he should deal with it instead of &quot;i&#039;ll-leave-it-for-later-maybe-it-will-not-happen-crossing-my-fingers&quot;. 
That&#039;s why assert should behave like exceptions. You catch the problem, return from function or execute alternative path. I&#039;ve seen that in one game (ASSERT_RETURN and ASSERT_ELSE).
Stoping the game/tool on assert doesn&#039;t do anything good. It may be good for a 1-2 programmers and some pedantic manager. But it is never good for an user.
If you really, really, really want to stop the game on the ASSERT, do this ONLY during initialization. Stoping the game/tool in the middle of the session is a really bad thing and a complete waste of time for an user/tester/artist/designer etc. ESPECIALLY in the tool in which single assert may waste 2-3hrs of work.
Of course that is why also you need a lead/manager who will catch a problem ASAP and find anyone whos responsible for this.</description>
		<content:encoded><![CDATA[<p>I disagree that assert should stop execution. If a programmer foresees a problem in a particular place he should deal with it instead of &#8220;i&#8217;ll-leave-it-for-later-maybe-it-will-not-happen-crossing-my-fingers&#8221;.<br />
That&#8217;s why assert should behave like exceptions. You catch the problem, return from function or execute alternative path. I&#8217;ve seen that in one game (ASSERT_RETURN and ASSERT_ELSE).<br />
Stoping the game/tool on assert doesn&#8217;t do anything good. It may be good for a 1-2 programmers and some pedantic manager. But it is never good for an user.<br />
If you really, really, really want to stop the game on the ASSERT, do this ONLY during initialization. Stoping the game/tool in the middle of the session is a really bad thing and a complete waste of time for an user/tester/artist/designer etc. ESPECIALLY in the tool in which single assert may waste 2-3hrs of work.<br />
Of course that is why also you need a lead/manager who will catch a problem ASAP and find anyone whos responsible for this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://msinilo.pl/blog/?p=544&#038;cpage=1#comment-18948</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Thu, 07 Jan 2010 20:46:28 +0000</pubDate>
		<guid isPermaLink="false">http://msinilo.pl/blog/?p=544#comment-18948</guid>
		<description>Yes, I should have probably mentioned Charles&#039; article, it&#039;s one of the best on this subject. I stolen shut-up-the-compiler-in-release-build-but-don&#039;t-generate-any-code trick from it (sizeof(expr)).</description>
		<content:encoded><![CDATA[<p>Yes, I should have probably mentioned Charles&#8217; article, it&#8217;s one of the best on this subject. I stolen shut-up-the-compiler-in-release-build-but-don&#8217;t-generate-any-code trick from it (sizeof(expr)).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Noel</title>
		<link>http://msinilo.pl/blog/?p=544&#038;cpage=1#comment-18946</link>
		<dc:creator>Noel</dc:creator>
		<pubDate>Thu, 07 Jan 2010 17:54:32 +0000</pubDate>
		<guid isPermaLink="false">http://msinilo.pl/blog/?p=544#comment-18946</guid>
		<description>It doesn&#039;t do everything you want, but the assert implementation we used at Power of Two Games was the best I&#039;ve seen so far. Charles wrote all the details (plus MIT-licensed code) here: http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert</description>
		<content:encoded><![CDATA[<p>It doesn&#8217;t do everything you want, but the assert implementation we used at Power of Two Games was the best I&#8217;ve seen so far. Charles wrote all the details (plus MIT-licensed code) here: <a href="http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert" rel="nofollow">http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
