<?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: Asserting the Basics &#8211; Part IIb</title>
	<atom:link href="http://blog.rough-sea.com/2008/11/asserting-the-basics-part-iib/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.rough-sea.com/2008/11/asserting-the-basics-part-iib/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=asserting-the-basics-part-iib</link>
	<description>Indie game development</description>
	<lastBuildDate>Tue, 17 Jan 2012 22:45:48 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: steffenj</title>
		<link>http://blog.rough-sea.com/2008/11/asserting-the-basics-part-iib/comment-page-1/#comment-121</link>
		<dc:creator>steffenj</dc:creator>
		<pubDate>Wed, 25 Mar 2009 15:53:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.rough-sea.com/?p=242#comment-121</guid>
		<description>Ok, i admit somewhere i forgot that you&#039;re working with ActionScript. Obviously 3 mentions of AS weren&#039;t enough for me. ;)

Thanks especially for clarifying (2), that sounds a lot more reasonable to me now.</description>
		<content:encoded><![CDATA[<p>Ok, i admit somewhere i forgot that you&#8217;re working with ActionScript. Obviously 3 mentions of AS weren&#8217;t enough for me. <img src='http://blog.rough-sea.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Thanks especially for clarifying (2), that sounds a lot more reasonable to me now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manuel</title>
		<link>http://blog.rough-sea.com/2008/11/asserting-the-basics-part-iib/comment-page-1/#comment-120</link>
		<dc:creator>Manuel</dc:creator>
		<pubDate>Wed, 25 Mar 2009 14:51:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.rough-sea.com/?p=242#comment-120</guid>
		<description>Hi Steffen,

Thanks for your insight! You are absolutely right! I agree with you in every respect ... if I&#039;d be working in a C or C++ environment like you do. I do know those rules you pointed out. Still, I decided to violate them and there are good reasons to do so:

(1) Any return-logic inside an assert will never be removed.
We do not work with a pre-processor. The asserts stay in the production code. Yet, we definately try to make sure, that asserts do not have any other side effects, though!

(2) Early-outs prevent Flash from throwing any exceptions. While using exceptions is quite handy in a debug-player, they will silently crash any non-debug players without any message whatsoever. Doing it the way I decribed, we get a decent error message even when the game crashes in a web browser. 

(3) There is no way (that I know of) to savely show an assert message and then stop the processing of a Flash application as you can e.g. on PC or consoles. We solved this by simply leave the function early and then show a huge pop-up containing the assertion-message (in the next frame, which is simply the way flash works). The pop-up makes it impossible to continue to work with the game (although it still runs in the background). It doesn&#039;t matter if the game state is corrupted afterwards, you won&#039;t be able to see it.

(4) And it is a more convenient way to do the code-snipped you mentioned. ;)

Thinking about it makes me wonder if I should have given the whole thing a different name. This would prevent people from thinking I am an idiot for breaking the most vital rules associated with asserts. ;)

Cheers,
Manuel</description>
		<content:encoded><![CDATA[<p>Hi Steffen,</p>
<p>Thanks for your insight! You are absolutely right! I agree with you in every respect &#8230; if I&#8217;d be working in a C or C++ environment like you do. I do know those rules you pointed out. Still, I decided to violate them and there are good reasons to do so:</p>
<p>(1) Any return-logic inside an assert will never be removed.<br />
We do not work with a pre-processor. The asserts stay in the production code. Yet, we definately try to make sure, that asserts do not have any other side effects, though!</p>
<p>(2) Early-outs prevent Flash from throwing any exceptions. While using exceptions is quite handy in a debug-player, they will silently crash any non-debug players without any message whatsoever. Doing it the way I decribed, we get a decent error message even when the game crashes in a web browser. </p>
<p>(3) There is no way (that I know of) to savely show an assert message and then stop the processing of a Flash application as you can e.g. on PC or consoles. We solved this by simply leave the function early and then show a huge pop-up containing the assertion-message (in the next frame, which is simply the way flash works). The pop-up makes it impossible to continue to work with the game (although it still runs in the background). It doesn&#8217;t matter if the game state is corrupted afterwards, you won&#8217;t be able to see it.</p>
<p>(4) And it is a more convenient way to do the code-snipped you mentioned. <img src='http://blog.rough-sea.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Thinking about it makes me wonder if I should have given the whole thing a different name. This would prevent people from thinking I am an idiot for breaking the most vital rules associated with asserts. <img src='http://blog.rough-sea.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Cheers,<br />
Manuel</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: steffenj</title>
		<link>http://blog.rough-sea.com/2008/11/asserting-the-basics-part-iib/comment-page-1/#comment-119</link>
		<dc:creator>steffenj</dc:creator>
		<pubDate>Wed, 25 Mar 2009 11:14:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.rough-sea.com/?p=242#comment-119</guid>
		<description>if (assert(..)) return;

Ouch! It really hurts me to see that. So you don&#039;t want your function to crash? That&#039;s ok if it&#039;s a utilitarian function, like &quot;GetDebugName&quot; whose output is completely optional. Maybe even for something like a &quot;Goto&quot; command. So what if the NPC doesn&#039;t move, as long as the game doesn&#039;t crash. Or loading an asset, as in this case, then just use the default asset (checkerboard texture or default cube model or whatever).

Good. But as a general thing to build your asserts with return values, i don&#039;t know. First of all, there&#039;s a very common advice called &quot;don&#039;t put logic inside your asserts&quot;. I would turn this around and say &quot;don&#039;t build your logic around asserts&quot;. Most often, if the assert fails, the game already is in an undefined state and shouldn&#039;t continue.

But then again, and maybe that&#039;s the whole issue here, you are trying to build unit tests around your game code, and without some &quot;softness&quot; of error reporting (including delayed or disabled display of assert messages) it&#039;s really hard to get right. Maybe that should have been stressed more.

As a general rule of thumb i would say that unless you are 100% sure that exiting a function prematurely doesn&#039;t corrupt the game state, don&#039;t use assertion return values in your code flow.

Your example is just a more convenient way to do the following:

CClass* pPointer = GetPointer();
Assert(pPointer);
if (pPointer != NULL) { ... pPointer used here ... };

I would prefer the explicitness in such cases.</description>
		<content:encoded><![CDATA[<p>if (assert(..)) return;</p>
<p>Ouch! It really hurts me to see that. So you don&#8217;t want your function to crash? That&#8217;s ok if it&#8217;s a utilitarian function, like &#8220;GetDebugName&#8221; whose output is completely optional. Maybe even for something like a &#8220;Goto&#8221; command. So what if the NPC doesn&#8217;t move, as long as the game doesn&#8217;t crash. Or loading an asset, as in this case, then just use the default asset (checkerboard texture or default cube model or whatever).</p>
<p>Good. But as a general thing to build your asserts with return values, i don&#8217;t know. First of all, there&#8217;s a very common advice called &#8220;don&#8217;t put logic inside your asserts&#8221;. I would turn this around and say &#8220;don&#8217;t build your logic around asserts&#8221;. Most often, if the assert fails, the game already is in an undefined state and shouldn&#8217;t continue.</p>
<p>But then again, and maybe that&#8217;s the whole issue here, you are trying to build unit tests around your game code, and without some &#8220;softness&#8221; of error reporting (including delayed or disabled display of assert messages) it&#8217;s really hard to get right. Maybe that should have been stressed more.</p>
<p>As a general rule of thumb i would say that unless you are 100% sure that exiting a function prematurely doesn&#8217;t corrupt the game state, don&#8217;t use assertion return values in your code flow.</p>
<p>Your example is just a more convenient way to do the following:</p>
<p>CClass* pPointer = GetPointer();<br />
Assert(pPointer);<br />
if (pPointer != NULL) { &#8230; pPointer used here &#8230; };</p>
<p>I would prefer the explicitness in such cases.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

