<?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: An Anatomy of Despair:  Managers and Contexts</title>
	<atom:link href="http://gamearchitect.net/2008/09/13/an-anatomy-of-despair-managers-and-contexts/feed/" rel="self" type="application/rss+xml" />
	<link>http://gamearchitect.net/2008/09/13/an-anatomy-of-despair-managers-and-contexts/</link>
	<description>Musings on Game Engine Design</description>
	<lastBuildDate>Thu, 15 Jul 2010 23:11:36 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Emmanuel Deloget</title>
		<link>http://gamearchitect.net/2008/09/13/an-anatomy-of-despair-managers-and-contexts/comment-page-1/#comment-313</link>
		<dc:creator>Emmanuel Deloget</dc:creator>
		<pubDate>Thu, 15 Jul 2010 23:11:36 +0000</pubDate>
		<guid isPermaLink="false">http://gamearchitect.net/?p=18#comment-313</guid>
		<description>Hit my head with a club if I&#039;m wrong, but you&#039;re advocating:

* the use of managers
* grouping manager instances into a structure

Now, I might be a wrong doer, but that&#039;s a bit too much for me. 

* managers are low cohesion, high coupling classes that are typically very stable and concrete. (OK ; simplified reading gives: a manager is made of several parts that have little in common (low cohesion), involve a lot of dependencies (high coupling), are difficult to modify because they are used everywhere (very stable), and cannot be extended because they use no abstraction (concrete)). That&#039;s a 0 out of 4 in the realm of &#039;do the correct design&#039;. Most managers can be implemented as a factory, a collection and possibly a cache. That&#039;s 3 parts, and that should be 3 classes. The behavior of the factory, the collection and the cache should be modifiable, so that even if they are coupled, they are not coupled to other part of the software. There is no such thing as a manager. 

* library context - wait, what&#039;s that? As I read your description, it appears to me that it&#039;s a God class.

I kind of agree with you: neither managers nor contexts are perfect. I would go farther than you in your conclusion: I bet that if you&#039;d stayed far away from both managers and contexts, you&#039;d be safer in the ever-more complex virtual world. I would love to see a dependency graph of Despair. OK, maybe not (frankly, 50 libraries, most of them with a manager?)

BTW, I really love your blog. It&#039;s just that post... Sorry.</description>
		<content:encoded><![CDATA[<p>Hit my head with a club if I&#8217;m wrong, but you&#8217;re advocating:</p>
<p>* the use of managers<br />
* grouping manager instances into a structure</p>
<p>Now, I might be a wrong doer, but that&#8217;s a bit too much for me. </p>
<p>* managers are low cohesion, high coupling classes that are typically very stable and concrete. (OK ; simplified reading gives: a manager is made of several parts that have little in common (low cohesion), involve a lot of dependencies (high coupling), are difficult to modify because they are used everywhere (very stable), and cannot be extended because they use no abstraction (concrete)). That&#8217;s a 0 out of 4 in the realm of &#8216;do the correct design&#8217;. Most managers can be implemented as a factory, a collection and possibly a cache. That&#8217;s 3 parts, and that should be 3 classes. The behavior of the factory, the collection and the cache should be modifiable, so that even if they are coupled, they are not coupled to other part of the software. There is no such thing as a manager. </p>
<p>* library context &#8211; wait, what&#8217;s that? As I read your description, it appears to me that it&#8217;s a God class.</p>
<p>I kind of agree with you: neither managers nor contexts are perfect. I would go farther than you in your conclusion: I bet that if you&#8217;d stayed far away from both managers and contexts, you&#8217;d be safer in the ever-more complex virtual world. I would love to see a dependency graph of Despair. OK, maybe not (frankly, 50 libraries, most of them with a manager?)</p>
<p>BTW, I really love your blog. It&#8217;s just that post&#8230; Sorry.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Julien</title>
		<link>http://gamearchitect.net/2008/09/13/an-anatomy-of-despair-managers-and-contexts/comment-page-1/#comment-220</link>
		<dc:creator>Julien</dc:creator>
		<pubDate>Fri, 30 Oct 2009 14:29:09 +0000</pubDate>
		<guid isPermaLink="false">http://gamearchitect.net/?p=18#comment-220</guid>
		<description>Very nice post, I really enjoy those insights in professional game development, thanks a lot for sharing.

I have encountered some of the issues you present in the development of the Phoenix engine* for my uni course.
Here&#039;s my take at solving the singleton hell:
Andrei Alexandrescu describes in his book Modern C++ Design a complex singleton template based on policy classes.

Those policies allow a lot of customization of the behavior of the singleton; one of those policies being the singletonWithLongevity.

Essentially each singleton class specify a static function that returns its longevity as an unsigned int in its class declaration body.

The policy uses that number when it builds a list of singletons to sort them by order of destruction.
It then registers each of them with atexit.
Singleton instantiation is JIT.

When one needs to know if they can access a singleton from another singleton, it&#039;s a simple matter of looking up in the header file for the getLongevity method and comparing the numbers.

Now for the icing on the cake, by using Alexandrescu&#039;s static_check (or compile time assertion) and the static longevity number, checking and changing the order of destruction of the singletons becomes a breeze :)

Of course the whole thing is thread-safe thanks to the threading policy.

* For the story, the name comes from the fact that every semester we pretty much rebuild the engine from &quot;scratch&quot; but keeping the good elements from the previous design.
Like the Phoenix, it never really dies :)</description>
		<content:encoded><![CDATA[<p>Very nice post, I really enjoy those insights in professional game development, thanks a lot for sharing.</p>
<p>I have encountered some of the issues you present in the development of the Phoenix engine* for my uni course.<br />
Here&#8217;s my take at solving the singleton hell:<br />
Andrei Alexandrescu describes in his book Modern C++ Design a complex singleton template based on policy classes.</p>
<p>Those policies allow a lot of customization of the behavior of the singleton; one of those policies being the singletonWithLongevity.</p>
<p>Essentially each singleton class specify a static function that returns its longevity as an unsigned int in its class declaration body.</p>
<p>The policy uses that number when it builds a list of singletons to sort them by order of destruction.<br />
It then registers each of them with atexit.<br />
Singleton instantiation is JIT.</p>
<p>When one needs to know if they can access a singleton from another singleton, it&#8217;s a simple matter of looking up in the header file for the getLongevity method and comparing the numbers.</p>
<p>Now for the icing on the cake, by using Alexandrescu&#8217;s static_check (or compile time assertion) and the static longevity number, checking and changing the order of destruction of the singletons becomes a breeze <img src='http://gamearchitect.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Of course the whole thing is thread-safe thanks to the threading policy.</p>
<p>* For the story, the name comes from the fact that every semester we pretty much rebuild the engine from &#8220;scratch&#8221; but keeping the good elements from the previous design.<br />
Like the Phoenix, it never really dies <img src='http://gamearchitect.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tomas</title>
		<link>http://gamearchitect.net/2008/09/13/an-anatomy-of-despair-managers-and-contexts/comment-page-1/#comment-50</link>
		<dc:creator>Tomas</dc:creator>
		<pubDate>Thu, 09 Oct 2008 22:49:43 +0000</pubDate>
		<guid isPermaLink="false">http://gamearchitect.net/?p=18#comment-50</guid>
		<description>There&#039;s an idea that I always wanted to try but have never gotten the chance to.

The problem with singletons is that you can never make a system independent of other systems if they are pulling each other&#039;s singletons into themselves left and right. How about if each system declares an interface - file system, memory allocation, and the like - and then an outside system injects the implementation of those interfaces into the various subsystems.

The disadvantages are, as I see them:

* Virtual call overhead (and lack of inlining etc)
* Lots of boilerplate code to make your actual file system (eg) implementation adhere to the various subsystems&#039; file system interfaces.

The advantages are:

* Total decoupling of systems, leading to...
* Reuseability of the systems since other clients can now cherry-pick the systems they want without getting the whole code base with it.</description>
		<content:encoded><![CDATA[<p>There&#8217;s an idea that I always wanted to try but have never gotten the chance to.</p>
<p>The problem with singletons is that you can never make a system independent of other systems if they are pulling each other&#8217;s singletons into themselves left and right. How about if each system declares an interface &#8211; file system, memory allocation, and the like &#8211; and then an outside system injects the implementation of those interfaces into the various subsystems.</p>
<p>The disadvantages are, as I see them:</p>
<p>* Virtual call overhead (and lack of inlining etc)<br />
* Lots of boilerplate code to make your actual file system (eg) implementation adhere to the various subsystems&#8217; file system interfaces.</p>
<p>The advantages are:</p>
<p>* Total decoupling of systems, leading to&#8230;<br />
* Reuseability of the systems since other clients can now cherry-pick the systems they want without getting the whole code base with it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Guillaume</title>
		<link>http://gamearchitect.net/2008/09/13/an-anatomy-of-despair-managers-and-contexts/comment-page-1/#comment-30</link>
		<dc:creator>Guillaume</dc:creator>
		<pubDate>Wed, 17 Sep 2008 19:58:06 +0000</pubDate>
		<guid isPermaLink="false">http://gamearchitect.net/?p=18#comment-30</guid>
		<description>As usual, very interesting to read.
Thanks for sharing Kyle !</description>
		<content:encoded><![CDATA[<p>As usual, very interesting to read.<br />
Thanks for sharing Kyle !</p>
]]></content:encoded>
	</item>
</channel>
</rss>
