<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Open Source Web Thoughts &#187; mvc</title>
	<atom:link href="http://blog.dewaldbotha.co.za/tag/mvc/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dewaldbotha.co.za</link>
	<description></description>
	<lastBuildDate>Fri, 25 Nov 2011 09:17:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>game theory pattern code example</title>
		<link>http://blog.dewaldbotha.co.za/2009/02/17/game-theory-pattern-code-example/</link>
		<comments>http://blog.dewaldbotha.co.za/2009/02/17/game-theory-pattern-code-example/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 08:50:50 +0000</pubDate>
		<dc:creator>dewaldbotha</dc:creator>
				<category><![CDATA[design patterns]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[game theory]]></category>

		<guid isPermaLink="false">http://blog.dewaldbotha.co.za/2009-02-17/game-theory-pattern-code-example/</guid>
		<description><![CDATA[so i finally took the time to write some code to better articulate my thoughts on &#8216;game theory pattern&#8217;. /* * Abstract Unifier class to select objects from different sources. */ abstract class childObjectUnifier { protected $currentObjectLocation; public function __construct() { $this->currentObjectLocation = get_class($this); } public function getData() { switch ($this->currentObjectLocation) { case 'currentServerLoginObject': return <a href="http://blog.dewaldbotha.co.za/2009/02/17/game-theory-pattern-code-example/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>so i finally took the time to write some code to better articulate my thoughts on &#8216;game theory pattern&#8217;.</p>
<pre lang="php">
/*
* Abstract Unifier class to select objects from different sources.
*/

abstract class childObjectUnifier
{
    protected $currentObjectLocation;

    public function __construct()
    {
        $this->currentObjectLocation = get_class($this);
    }

    public function getData()
    {
        switch ($this->currentObjectLocation)
        {
             case 'currentServerLoginObject':
                    return $this->currentServerLoginFunction();
                    break;

             case 'remoteServerLoginObject':
                    return $this->remoteServerLoginFunction();
                    break;

             default:
                    die('Current user load not available');
        }
    }
}

/*
* Login Object which exists on the current server.
* This object could still be hit on the current server if the current user load is not high.
* Better utilizes the current server.
*/

class currentServerLoginObject extends childObjectUnifier
{
    public function currentServerLoginFunction()
    {
         return 'Some function on the current server';
    }
}

/*
* This login object could exist remotely, for e.g. a restfull/soap/xml-rpc service
* which could be hit if the current server load is climbing.
* Could possibly use a dedicated 'login' server if user load is exceedingly high on current machine.
*/

class remoteServerLoginObject extends childObjectUnifier
{
    public function remoteServerLoginFunction()
    {
        return 'Some function on the remote server';
    }
}

/*
* The game theory pattern which decides which objects to instantiate based on logical
* decisions made by solid data.
* In this example the current user load.
*/

class GameTheoryPattern
{
    public $currentObject;

    function __construct($iCurrentUserLoad)
    {
        $this->currentObject = $this->baseObjectUponStrategicData($iCurrentUserLoad);
    }

    private function baseObjectUponStrategicData($iCurrentUserLoad)
    {
         switch ($iCurrentUserLoad)
         {
             case $iCurrentUserLoad < 1000:
                    return new currentServerLoginObject();
                    break;

             case $iCurrentUserLoad >= 1000 :
                    return new remoteServerLoginObject();
                    break;

             default:
                    die('Current user load not available');
        }
    }
}

//GetCurrentUserLoad
$iCurrentUserLoad = 1000;

//Create Login Object based on the Game Theory Pattern
$oLogin = new GameTheoryPattern($iCurrentUserLoad);

//Call an function from the unifier class
echo $oLogin->currentObject->getData();

?></pre>
<p>It should be pretty self explanatory &#8211; due to the high level comments <img src='http://blog.dewaldbotha.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>feel free to add suggestions or comments &#8211; since i&#8217;m pretty sure there could be a better way, but for now, just to convey the message it should be sufficient.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dewaldbotha.co.za/2009/02/17/game-theory-pattern-code-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>applying game theory patterns to development</title>
		<link>http://blog.dewaldbotha.co.za/2009/02/11/applying-game-theory-patterns-to-development/</link>
		<comments>http://blog.dewaldbotha.co.za/2009/02/11/applying-game-theory-patterns-to-development/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 07:29:23 +0000</pubDate>
		<dc:creator>dewaldbotha</dc:creator>
				<category><![CDATA[architecture]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[game theory pattern]]></category>
		<category><![CDATA[software architecture]]></category>

		<guid isPermaLink="false">http://blog.dewaldbotha.co.za/2009-02-11/applying-game-theory-patterns-to-development/</guid>
		<description><![CDATA[mobile &#8211; that damned device that makes our life so easy, yet sometimes so inheritely difficult. as a developer, we kind of try and convince ourselves that developing for mobile and developing for a desktop browser is kind of the same thing.  but we all know that this is a stalling technique for the inevitable, <a href="http://blog.dewaldbotha.co.za/2009/02/11/applying-game-theory-patterns-to-development/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>mobile &#8211; that damned device that makes our life so easy, yet sometimes so inheritely difficult.</p>
<p>as a developer, we kind of try and convince ourselves that developing for <a href="http://mobiforge.com" title="Mobiforge" target="_blank">mobile</a> and developing for a desktop browser is kind of the same thing.  but we all know that this is a stalling technique for the inevitable, since invariably it becomes a whole different field of play.</p>
<p>every little feature you add, every little flow created and every branch of navigational hierarchy is a challenge on its own.</p>
<p><strong>enter the game theory pattern</strong></p>
<p><span id="more-14"></span>this is was where my idea of a <a href="http://en.wikipedia.org/wiki/Game_theory" title="Game Theory" target="_blank">game theory</a> patterns came into play.  game theory is a branch of applied mathematics, most notably used in social sciences (economics, biology, engineering etc.).  it is also used a bit in computer science, although referred to in that field as artificial intelligence.</p>
<p>thanks <a href="http://wikipedia.org" title="Wikipedia" target="_blank">wikipedia</a> <img src='http://blog.dewaldbotha.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>game theory allows someone to apply a bit of mathematics to capture data from a situation and use that data to build a strategic base, which allows you to make decisions to determine your success.</p>
<p>take for example morning traffic &#8211; you have 2 routes to take to work &#8211; one a bit longer than the other, but the longer route is less likely to be busy.</p>
<p>what do you do?  most of us will take the pro&#8217;s and con&#8217;s of both routes and use that to base our decision upon.</p>
<p>game theory works exactly, well almost, the same.  except you will probably use a bit of math to finalize your decision (average speed, distance etc.)</p>
<p>so why not use game theory in development, especially in a field like mobile, which is very limiting and very frustating at first.  but the good kind of limitation, the kind of limitation that could possibly create innovation.  the guys behind a phenomenon like <a href="http://twitter.com" title="Twitter" target="_blank">twitter</a> decided to limit people to 140 characters.  and despite this limitation, people have found innovative ways to increase the effect of that 140 character limited textual communication.</p>
<p>game theory would allow us to mathematically decide on feature sets, the use of algorythms, objects and could even change the flow of an application.</p>
<p>say on an example mobile application we have 3 major features &#8211; chat, activity, content sharing.</p>
<p>which one do we choose as our killer feature, and which would probably make the application more bloated and more problematic to use.  why not use the main variable in the equation to help you decide &#8211; the user.</p>
<p>i often secretly chuckle to myself, when a system gets developed for one purpose and all the users start using it for a totally different end result, no one really every thought of, or intended for.  you could use this to your advantage with game theory.</p>
<p>a simple case could be made using application flow as an example.  we have a menu with chat, activity feed and shared content.  which one is more important, which one would you make easier to access for the user.  by simply adding a click count to each feature, you could sort a menu by popularity, rather than obvious choice as this will invariably change someday.</p>
<p>if users decide this month, chat is the next best thing, let chat be number one on your menu &#8211; and i know some user interface expert will maintain that consistency is important, but if users consistently choose chat as their most important feature, what would the issue be?</p>
<p>this would change the way you develop and architecture software as well.  since you know chat is gaining in popularity according to your available data, then you should be able to utilize servers better for your chat functionality.  write scaling scripts which would use databases sharding.  and on the other hand, allow your game theory pattern to simplify things &#8211; why use a 40 slave/master instances of a database if all you need is one.  eliminate unnecessary overheads in that way &#8211; more layers makes for more complexity, makes for more overhead, and will eventually kill your application.</p>
<p>i&#8217;ve still got to convince a couple of people to maybe try this game theory pattern approach to development and if, by chance, <a href="http://martinfowler.com/" title="Martin Fowler" target="_blank">martin fowler</a> reads this article:</p>
<p>&#8216;please martin, consider this pattern as a topic for a new book! <img src='http://blog.dewaldbotha.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> &#8217;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dewaldbotha.co.za/2009/02/11/applying-game-theory-patterns-to-development/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

