<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
	<title>Comments for games.greggman.com</title>
	
	<link>http://games.greggman.com/game</link>
	<description>Games, Code and Game Development</description>
	<lastBuildDate>Sat, 13 Mar 2010 02:09:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/CommentsForGamesgreggmancom" /><feedburner:info uri="commentsforgamesgreggmancom" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Comment on TGA Thumbnails for Windows by -</title>
		<link>http://feedproxy.google.com/~r/CommentsForGamesgreggmancom/~3/An6qIQWyRc4/</link>
		<dc:creator>-</dc:creator>
		<pubDate>Sat, 13 Mar 2010 02:09:22 +0000</pubDate>
		<guid isPermaLink="false">http://games.greggman.com/game/tga_thumbnails_for_windows/#comment-35443</guid>
		<description>Great Program

The one annoying aspect about this program is that it does not handle partial/complete transparency very well. Right now every pixel is displayed regardless of whether it is meant to be transparent or not. In other words each picture is displayed as though it has no transparency regardless of whether or not this is actually the case.</description>
		<content:encoded><![CDATA[<p>Great Program</p>
<p>The one annoying aspect about this program is that it does not handle partial/complete transparency very well. Right now every pixel is displayed regardless of whether it is meant to be transparent or not. In other words each picture is displayed as though it has no transparency regardless of whether or not this is actually the case.</p>
]]></content:encoded>
	<feedburner:origLink>http://games.greggman.com/game/tga_thumbnails_for_windows/comment-page-3/#comment-35443</feedburner:origLink></item>
	<item>
		<title>Comment on Computer Geek circa 1984 by patience udall</title>
		<link>http://feedproxy.google.com/~r/CommentsForGamesgreggmancom/~3/v5X9ux8UpLs/</link>
		<dc:creator>patience udall</dc:creator>
		<pubDate>Sun, 07 Mar 2010 07:49:48 +0000</pubDate>
		<guid isPermaLink="false">http://games.greggman.com/game/computer_geek_circa_1984/#comment-35370</guid>
		<description>What a kick to see the good old days back.... what memories!! are you still actively answering your site?</description>
		<content:encoded><![CDATA[<p>What a kick to see the good old days back&#8230;. what memories!! are you still actively answering your site?</p>
]]></content:encoded>
	<feedburner:origLink>http://games.greggman.com/game/computer_geek_circa_1984/comment-page-1/#comment-35370</feedburner:origLink></item>
	<item>
		<title>Comment on Designing Better APIs by greggman</title>
		<link>http://feedproxy.google.com/~r/CommentsForGamesgreggmancom/~3/L28PRXseqFU/</link>
		<dc:creator>greggman</dc:creator>
		<pubDate>Tue, 01 Dec 2009 21:05:20 +0000</pubDate>
		<guid isPermaLink="false">http://games.greggman.com/game/designing_better_apis/#comment-33605</guid>
		<description>I could make GetSharedMemoryAs like this

&lt;code&gt;template &lt;typename T&gt;
bool GetSharedMemoryAs(
    int shared_memory_id,
    int shared_memory_offset,
    size_t size,
    T* pointer) {
  *pointer = GetSharedMemory(
      shared_memory_id,
      shared_memory_offset,
      size);

   return *pointer != NULL;
}&lt;/code&gt;
Or something along those lines. That would actually make it less typing and easier to use since you don't have to specify the type. Then you can just do

&lt;code&gt;
int* some_ints;
mem_sys-&gt;GetSharedMemoryAs(id, offset, size, &amp;some_ints);
&lt;/code&gt;

Personally I'd make "pointer* a reference to a pointer if it was up to me but my company doesn't allow non-const references.</description>
		<content:encoded><![CDATA[<p>I could make GetSharedMemoryAs like this</p>
<pre class="prettyprint" >template <typename T>
bool GetSharedMemoryAs(
    int shared_memory_id,
    int shared_memory_offset,
    size_t size,
    T* pointer) {
  *pointer = GetSharedMemory(
      shared_memory_id,
      shared_memory_offset,
      size);

   return *pointer != NULL;
}</typename></pre>
<p>Or something along those lines. That would actually make it less typing and easier to use since you don&#8217;t have to specify the type. Then you can just do</p>
<pre class="prettyprint" >
int* some_ints;
mem_sys->GetSharedMemoryAs(id, offset, size, &#038;some_ints);
</pre>
<p>Personally I&#8217;d make &#8220;pointer* a reference to a pointer if it was up to me but my company doesn&#8217;t allow non-const references.</p>
]]></content:encoded>
	<feedburner:origLink>http://games.greggman.com/game/designing_better_apis/comment-page-1/#comment-33605</feedburner:origLink></item>
	<item>
		<title>Comment on p4reconcile by pauly</title>
		<link>http://feedproxy.google.com/~r/CommentsForGamesgreggmancom/~3/1IRhB22-Zdw/</link>
		<dc:creator>pauly</dc:creator>
		<pubDate>Mon, 30 Nov 2009 16:19:52 +0000</pubDate>
		<guid isPermaLink="false">http://games.greggman.com/game/p4reconcile/#comment-33608</guid>
		<description>I think I originally got this from Perforce via support email. I've found Perforce's knowledge base contains some gems, but only when you know where to look....</description>
		<content:encoded><![CDATA[<p>I think I originally got this from Perforce via support email. I&#8217;ve found Perforce&#8217;s knowledge base contains some gems, but only when you know where to look&#8230;.</p>
]]></content:encoded>
	<feedburner:origLink>http://games.greggman.com/game/p4reconcile/comment-page-1/#comment-33608</feedburner:origLink></item>
	<item>
		<title>Comment on Designing Better APIs by pauly</title>
		<link>http://feedproxy.google.com/~r/CommentsForGamesgreggmancom/~3/ZLeNtoH80Cs/</link>
		<dc:creator>pauly</dc:creator>
		<pubDate>Mon, 30 Nov 2009 16:17:02 +0000</pubDate>
		<guid isPermaLink="false">http://games.greggman.com/game/designing_better_apis/#comment-33604</guid>
		<description>Are you just talking about "inline" as it applies to templates only? Its certainly more than a hint in non-template functions. In template functions, the worst that can happen is that compiler will take the hint, and even improve compile times. There's a good article about inline-only template functions in the Meyer's book (I don't have the book to hand, unfortunately).



With all these small allocations, might it not better to add a heap manager, ie. a malloc-style heap management? I can see reasons to NOT do that with shared memory (eg. process A shares memory with process B and process C, but doesn't want process B and C to see the each others data).



Compile times over safety? Mmmmm, what's the cost? :) In this case, the template function is no more safe (and not even less typing) than the original, so nothing is gained. But I'm being picky. There's nothing really wrong with your function - its one of the best uses of templates IMHO.</description>
		<content:encoded><![CDATA[<p>Are you just talking about &#8220;inline&#8221; as it applies to templates only? Its certainly more than a hint in non-template functions. In template functions, the worst that can happen is that compiler will take the hint, and even improve compile times. There&#8217;s a good article about inline-only template functions in the Meyer&#8217;s book (I don&#8217;t have the book to hand, unfortunately).</p>
<p>With all these small allocations, might it not better to add a heap manager, ie. a malloc-style heap management? I can see reasons to NOT do that with shared memory (eg. process A shares memory with process B and process C, but doesn&#8217;t want process B and C to see the each others data).</p>
<p>Compile times over safety? Mmmmm, what&#8217;s the cost? <img src='http://games.greggman.com/ctrl/wp-game/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  In this case, the template function is no more safe (and not even less typing) than the original, so nothing is gained. But I&#8217;m being picky. There&#8217;s nothing really wrong with your function &#8211; its one of the best uses of templates IMHO.</p>
]]></content:encoded>
	<feedburner:origLink>http://games.greggman.com/game/designing_better_apis/comment-page-1/#comment-33604</feedburner:origLink></item>
	<item>
		<title>Comment on Designing Better APIs by greggman</title>
		<link>http://feedproxy.google.com/~r/CommentsForGamesgreggmancom/~3/KNHLgJAGyf4/</link>
		<dc:creator>greggman</dc:creator>
		<pubDate>Mon, 30 Nov 2009 10:31:31 +0000</pubDate>
		<guid isPermaLink="false">http://games.greggman.com/game/designing_better_apis/#comment-33603</guid>
		<description>There's no reason to add "inline". The compiler will do it for you. In fact, it's waste of typing and as it's only a suggestion to the compiler it is mis-leading since you don't know if it will be inlined. (besides, it's against my current employer's style guide)



As for it being bad design, the function argument clearly says "page size" and is therefore auto documented so the API user is not going to use bytes by accident. You instantly know you have to look up the page size whether it's a constant or from a function. That's much better than having no idea. I could certainly see improving it by naming the function, AllocatePagesOfSharedMemory or AllocateSharedMemoryPages which would make it even clearer.



As someone who had to debug and fix code because an API designer choose the "number of bytes" solution and the client code saw "number of bytes" and was allocating lots of small amounts that way I'm going on empirical evidence. I'm also not the only one to run into this. A 40% increase in speed was recently had by one of the teams at my company finding out they were using a similar API inefficiently by allocating lots of small pieces of memory when internally it was allocating pages and therefore filling memory and ending up paging the app.



Hiding something that important is the wrong API design. A good design helps you write code that uses the API the way it was intended to be used. Bad API design puts all the burden of figuring out both how to use it at all and how to use it efficiently on the shoulders of the API user.



As for compile times, I hope you're not saying you'd choose compile times over safety.</description>
		<content:encoded><![CDATA[<p>There&#8217;s no reason to add &#8220;inline&#8221;. The compiler will do it for you. In fact, it&#8217;s waste of typing and as it&#8217;s only a suggestion to the compiler it is mis-leading since you don&#8217;t know if it will be inlined. (besides, it&#8217;s against my current employer&#8217;s style guide)</p>
<p>As for it being bad design, the function argument clearly says &#8220;page size&#8221; and is therefore auto documented so the API user is not going to use bytes by accident. You instantly know you have to look up the page size whether it&#8217;s a constant or from a function. That&#8217;s much better than having no idea. I could certainly see improving it by naming the function, AllocatePagesOfSharedMemory or AllocateSharedMemoryPages which would make it even clearer.</p>
<p>As someone who had to debug and fix code because an API designer choose the &#8220;number of bytes&#8221; solution and the client code saw &#8220;number of bytes&#8221; and was allocating lots of small amounts that way I&#8217;m going on empirical evidence. I&#8217;m also not the only one to run into this. A 40% increase in speed was recently had by one of the teams at my company finding out they were using a similar API inefficiently by allocating lots of small pieces of memory when internally it was allocating pages and therefore filling memory and ending up paging the app.</p>
<p>Hiding something that important is the wrong API design. A good design helps you write code that uses the API the way it was intended to be used. Bad API design puts all the burden of figuring out both how to use it at all and how to use it efficiently on the shoulders of the API user.</p>
<p>As for compile times, I hope you&#8217;re not saying you&#8217;d choose compile times over safety.</p>
]]></content:encoded>
	<feedburner:origLink>http://games.greggman.com/game/designing_better_apis/comment-page-1/#comment-33603</feedburner:origLink></item>
	<item>
		<title>Comment on p4reconcile by greggman</title>
		<link>http://feedproxy.google.com/~r/CommentsForGamesgreggmancom/~3/oBzvGQt9oww/</link>
		<dc:creator>greggman</dc:creator>
		<pubDate>Mon, 30 Nov 2009 09:33:34 +0000</pubDate>
		<guid isPermaLink="false">http://games.greggman.com/game/p4reconcile/#comment-33607</guid>
		<description>&lt;div class="title"&gt;Awesome&lt;/div&gt;I'll have to try those out. Funny how Googling for a reconcile solution didn't bring up any (at the time I wrote the script)



Even p4's blog doesn't list your simple solution :-(

&lt;a href="http://blog.perforce.com/blog/?p=25" rel="nofollow"&gt;http://blog.perforce.com/blog/?p=25&lt;/a&gt;</description>
		<content:encoded><![CDATA[<div class="title">Awesome</div>
<p>I&#8217;ll have to try those out. Funny how Googling for a reconcile solution didn&#8217;t bring up any (at the time I wrote the script)</p>
<p>Even p4&#8217;s blog doesn&#8217;t list your simple solution <img src='http://games.greggman.com/ctrl/wp-game/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p><a href="http://blog.perforce.com/blog/?p=25" rel="nofollow">http://blog.perforce.com/blog/?p=25</a></p>
]]></content:encoded>
	<feedburner:origLink>http://games.greggman.com/game/p4reconcile/comment-page-1/#comment-33607</feedburner:origLink></item>
	<item>
		<title>Comment on p4reconcile by pauly</title>
		<link>http://feedproxy.google.com/~r/CommentsForGamesgreggmancom/~3/NJVnWgV830A/</link>
		<dc:creator>pauly</dc:creator>
		<pubDate>Sun, 29 Nov 2009 20:09:02 +0000</pubDate>
		<guid isPermaLink="false">http://games.greggman.com/game/p4reconcile/#comment-33606</guid>
		<description>I think these 3 lines of a .bat do the same thing:



p4 diff -sd ... | p4 -x - delete

p4 diff -se ... | p4 -x - edit

dir/s/b/a-d | p4 -x - add</description>
		<content:encoded><![CDATA[<p>I think these 3 lines of a .bat do the same thing:</p>
<p>p4 diff -sd &#8230; | p4 -x &#8211; delete</p>
<p>p4 diff -se &#8230; | p4 -x &#8211; edit</p>
<p>dir/s/b/a-d | p4 -x &#8211; add</p>
]]></content:encoded>
	<feedburner:origLink>http://games.greggman.com/game/p4reconcile/comment-page-1/#comment-33606</feedburner:origLink></item>
	<item>
		<title>Comment on Designing Better APIs by pauly</title>
		<link>http://feedproxy.google.com/~r/CommentsForGamesgreggmancom/~3/lL96MVx4AiQ/</link>
		<dc:creator>pauly</dc:creator>
		<pubDate>Sun, 29 Nov 2009 20:02:29 +0000</pubDate>
		<guid isPermaLink="false">http://games.greggman.com/game/designing_better_apis/#comment-33602</guid>
		<description>void* AllocateSharedMemory(size_t number_of_pages) is a poor design. It puts the work of calculating the number of pages on the application programmer - every single time - leading to more chance of error. If this function is called in many places, it would be easy to accidently pass in "number of bytes" instead of "number of pages", and never catch it.



Now what happens if the page size changes? Or I add a second page size? At the very least I would have to recompile all client code - a major fail for an API. At the very least, you should be passing some kind of page size or page size enum.



Also, the intention of the original API seems to be to hide the page size from the application programmer. I agree that "Asserting" is a major fail, but the original API might be trying to hide the page size for a very good reason.





On your second example, I think you are missing the difference between an "API" and "Helper functions". To me, a good API provides basic functionality, whilst helper functions group a series of commonly used functions together. I think your final example is a helper function, not an API function.



Oh, and my compile times might not thank you for adding templates into your header file, but I guess its just one (inline - please add inline!) function :)</description>
		<content:encoded><![CDATA[<p>void* AllocateSharedMemory(size_t number_of_pages) is a poor design. It puts the work of calculating the number of pages on the application programmer &#8211; every single time &#8211; leading to more chance of error. If this function is called in many places, it would be easy to accidently pass in &#8220;number of bytes&#8221; instead of &#8220;number of pages&#8221;, and never catch it.</p>
<p>Now what happens if the page size changes? Or I add a second page size? At the very least I would have to recompile all client code &#8211; a major fail for an API. At the very least, you should be passing some kind of page size or page size enum.</p>
<p>Also, the intention of the original API seems to be to hide the page size from the application programmer. I agree that &#8220;Asserting&#8221; is a major fail, but the original API might be trying to hide the page size for a very good reason.</p>
<p>On your second example, I think you are missing the difference between an &#8220;API&#8221; and &#8220;Helper functions&#8221;. To me, a good API provides basic functionality, whilst helper functions group a series of commonly used functions together. I think your final example is a helper function, not an API function.</p>
<p>Oh, and my compile times might not thank you for adding templates into your header file, but I guess its just one (inline &#8211; please add inline!) function <img src='http://games.greggman.com/ctrl/wp-game/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	<feedburner:origLink>http://games.greggman.com/game/designing_better_apis/comment-page-1/#comment-33602</feedburner:origLink></item>
	<item>
		<title>Comment on Designing Better APIs by CarlJohan</title>
		<link>http://feedproxy.google.com/~r/CommentsForGamesgreggmancom/~3/Pz9rjV4fmwo/</link>
		<dc:creator>CarlJohan</dc:creator>
		<pubDate>Fri, 27 Nov 2009 14:20:23 +0000</pubDate>
		<guid isPermaLink="false">http://games.greggman.com/game/designing_better_apis/#comment-33601</guid>
		<description>Your pictures don't show up very much in the rss feed :(</description>
		<content:encoded><![CDATA[<p>Your pictures don&#8217;t show up very much in the rss feed <img src='http://games.greggman.com/ctrl/wp-game/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
	<feedburner:origLink>http://games.greggman.com/game/designing_better_apis/comment-page-1/#comment-33601</feedburner:origLink></item>
</channel>
</rss>
