<?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>Pixelatom</title>
	<atom:link href="http://www.pixelatom.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pixelatom.com</link>
	<description>High Quality Web Development</description>
	<lastBuildDate>Fri, 30 Nov 2012 19:06:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>The impact of the new aspect-ratio of iphone in the indie game development industry</title>
		<link>http://www.pixelatom.com/impact-aspect-ratio-iphone-indie-game-development-industry/</link>
		<comments>http://www.pixelatom.com/impact-aspect-ratio-iphone-indie-game-development-industry/#comments</comments>
		<pubDate>Tue, 18 Sep 2012 19:49:13 +0000</pubDate>
		<dc:creator>Elezeta</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[compatibility]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[iphone 5]]></category>
		<category><![CDATA[resolution]]></category>
		<category><![CDATA[video games]]></category>

		<guid isPermaLink="false">http://www.pixelatom.com/?p=427</guid>
		<description><![CDATA[As many of you already know, the last keynote of apple introduced the brand new iPhone 5 where one of the biggest change, pops up at plain sight: a weird aspect ratio. Since they decided leaving width exactly as is predecessor, they added about 176 pixels of heigh making the new resolution to be  640 x 1136. [...]]]></description>
				<content:encoded><![CDATA[<p>As many of you already know, the last keynote of apple introduced the brand new iPhone 5 where one of the biggest change, pops up at plain sight: <strong>a weird aspect ratio</strong>. Since they decided leaving width exactly as is predecessor, <strong>they added about 176 pixels of heigh</strong> making <strong>the new resolution to be  640 x 1136</strong>.</p>
<p>Even thought they say it was for a better gaming experience (which I do not argue, bigger screen is usually better for videogames), there&#8217;s something we have to consider: <strong>What is the imapct of this new resolution in indie games development?</strong></p>
<p>Many games technologies let you to compile the game into different platforms including iOS  6. However when we talk about games, a difference in pixels makes a huge difference in the gameplay. This issue turns even more complicated when we talk about pixelart.</p>
<p>In our case, we have our game almost <strong>ready to be launched</strong>. However we cannot silence the several questions that come to our minds:</p>
<ul>
<li>How fast will development platform add the compatibility for this new device?</li>
<li>Will X-Code be modified in order to compile with the new specs?</li>
<li>Will Apple approve our apps if they&#8217;re not compatible with last iPhone resolution?</li>
<li>Should we wait launch until the platform we are using add the support to this new device?</li>
<li>Should we re-build the game in order to be fully compatible with all devices prior launch?</li>
</ul>
<p>I think many developers are asking themselves the same thing. I just hope this is not turning into a lot of development hours just to keep our products in the Apple Store.</p>
<p><strong>Edit</strong>: I&#8217;ve been looking through different forums and it seems there is a popular uncertainty across different platforms (<a href="http://www.cocos2d-iphone.org/forum/topic/39491">Cocos 2d</a>, <a href="http://forum.unity3d.com/threads/150981-1136x640-iPhone-5-Resolution">Unity</a>, <a href="http://forum.bennugd.org/">Bennu GD</a>). And even thought there are some patches to try in the iphone emulator, the response is generalized: <strong>we have to wait to see what happen</strong>.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelatom.com/impact-aspect-ratio-iphone-indie-game-development-industry/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Design Patterns php implementations: Singleton</title>
		<link>http://www.pixelatom.com/design-patterns-php-singleton/</link>
		<comments>http://www.pixelatom.com/design-patterns-php-singleton/#comments</comments>
		<pubDate>Fri, 07 Sep 2012 20:50:10 +0000</pubDate>
		<dc:creator>Javis</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Pixelatom]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[patterns]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[singleton]]></category>
		<category><![CDATA[traits]]></category>

		<guid isPermaLink="false">http://www.pixelatom.com/?p=410</guid>
		<description><![CDATA[There are numerous ways to structure the code and project for you web application, and you can put as much or as little thought as you like into architecting. But it is usually a good idea to follow to common patterns because it will make your code easier to manage and easier for others to [...]
Related posts:<ol>
<li><a href='http://www.pixelatom.com/php-performance-tip-2-reduce-size-php-objects/' rel='bookmark' title='PHP Performance – Tip #2: Reduce the size of your PHP objects and be careful with static functions'>PHP Performance – Tip #2: Reduce the size of your PHP objects and be careful with static functions</a></li>
<li><a href='http://www.pixelatom.com/php-5-4-traits/' rel='bookmark' title='PHP 5.4 Traits'>PHP 5.4 Traits</a></li>
<li><a href='http://www.pixelatom.com/linxphp-2-namespaces/' rel='bookmark' title='The road to linxPHP 2: Namespaces'>The road to linxPHP 2: Namespaces</a></li>
</ol>]]></description>
				<content:encoded><![CDATA[<p>There are numerous ways to structure the code and project for you web application, and you can put as much or as little thought as you like into architecting. But it is usually a good idea to follow to common patterns because it will make your code easier to manage and easier for others to understand.</p>
<p>This time we&#8217;re going to review the Singleton dessign pattern, and the different ways it can implemented in PHP.</p>
<p>The  objetive of the Singleton pattern is to ensure a class has only one instance, and provide a global point of access to it. This is useful when exactly one object is needed to coordinate actions across the system.</p>
<p>Note the <strong>distinction</strong> between a simple static instance of a class and a singleton: although a singleton can be implemented as a static instance, it can also be lazily constructed, requiring no memory or resources until needed.</p>
<p><strong>Implementation</strong></p>
<p>The most common implementation of this pattern is as follows:</p><pre class="crayon-plain-tag">class MyClass { 

  // singleton instance 
  private static $instance; 

  // private constructor function 
  // to prevent external instantiation 
  private __construct() { } 

  // getInstance method 
  public static function getInstance() { 

    if(!self::$instance) { 
      self::$instance = new self(); 
    } 

    return self::$instance; 

  } 

  //... 

}</pre><p>The usage is pretty simple:</p><pre class="crayon-plain-tag">&amp;lt;?php
$instance = MyClass::getInstance();
?&amp;gt;</pre><p><strong> PHP 5.3 get_called_class() implementation</strong></p>
<p>Prior to PHP 5.3, inheriting Singleton classes had the problem that it always instantiated the super class. But now it is possible to write a completely self-contained Singleton base class in PHP 5.3 using the function get_called_class.</p><pre class="crayon-plain-tag">&amp;lt;?php 

abstract class Singleton { 

    protected function __construct() { 
    } 

    final public static function getInstance() { 
        static $aoInstance = array(); 

        $calledClassName = get_called_class(); 

        if (! isset ($aoInstance[$calledClassName])) { 
            $aoInstance[$calledClassName] = new $calledClassName(); 
        } 

        return $aoInstance[$calledClassName]; 
    } 

    final private function __clone() { 
    } 
} 

class DatabaseConnection extends Singleton { 

    protected $connection; 

    protected function __construct() { 
        // @todo Connect to the database 
    } 

    public function __destruct() { 
        // @todo Drop the connection to the database 
    } 
} 

$oDbConn = new DatabaseConnection();  // Fatal error 

$oDbConn = DatabaseConnection::getInstance();  // Returns single instance 
?&amp;gt;</pre><p><strong> PHP 5.4 Traits Implementation</strong></p>
<p>PHP 5.4 introduced <a href="http://php.net/manual/en/language.oop5.traits.php">Traits</a> as a solution to the limitations of single inheritance. With Traits we can also implement Singletons as the following way:</p><pre class="crayon-plain-tag">&amp;lt;?php

trait singleton {    
    /**
     * private construct, generally defined by using class
     */
    //private function __construct() {}

    public static function getInstance() {
        static $_instance = NULL;
        $class = __CLASS__;
        return $_instance ?: $_instance = new $class;
    }

    public function __clone() {
        trigger_error('Cloning '.__CLASS__.' is not allowed.',E_USER_ERROR);
    }

    public function __wakeup() {
        trigger_error('Unserializing '.__CLASS__.' is not allowed.',E_USER_ERROR);
    }
}

/**
 * Example Usage
 */

class foo {
    use singleton;

    private function __construct() {
        $this-&amp;gt;name = 'foo';
    }
}

class bar {
    use singleton;

    private function __construct() {
        $this-&amp;gt;name = 'bar';
    }
}

$foo = foo::getInstance();
echo $foo-&amp;gt;name;

$bar = bar::getInstance();
echo $bar-&amp;gt;name;</pre><p>Ta-Dah! we reviewed 3 different ways to implement the Singleton design pattern in PHP. Each one have it&#8217;s pros and cons, but it&#8217;s very interesting to see we have many alternatives supported in PHP to solve our problems in a standard way. Next time we&#8217;ll see how to implement other design patterns. Till then!</p>
<p>Related posts:</p><ol>
<li><a href='http://www.pixelatom.com/php-performance-tip-2-reduce-size-php-objects/' rel='bookmark' title='PHP Performance – Tip #2: Reduce the size of your PHP objects and be careful with static functions'>PHP Performance – Tip #2: Reduce the size of your PHP objects and be careful with static functions</a></li>
<li><a href='http://www.pixelatom.com/php-5-4-traits/' rel='bookmark' title='PHP 5.4 Traits'>PHP 5.4 Traits</a></li>
<li><a href='http://www.pixelatom.com/linxphp-2-namespaces/' rel='bookmark' title='The road to linxPHP 2: Namespaces'>The road to linxPHP 2: Namespaces</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://www.pixelatom.com/design-patterns-php-singleton/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Performance – Tip #4: Use a cache system</title>
		<link>http://www.pixelatom.com/php-performance-tip-4-cache-system/</link>
		<comments>http://www.pixelatom.com/php-performance-tip-4-cache-system/#comments</comments>
		<pubDate>Thu, 06 Sep 2012 00:42:58 +0000</pubDate>
		<dc:creator>Elezeta</dc:creator>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[apc]]></category>
		<category><![CDATA[linxphp]]></category>
		<category><![CDATA[memcache]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.pixelatom.com/?p=397</guid>
		<description><![CDATA[We are getting to the end of this series of performance tips and the most used performance tool could not be left out. We previously talked about loops, data structures, memory management, and even why we don&#8217;t consider that premature optimization is the root of all problem. So lets get down to business and start taking of [...]
Related posts:<ol>
<li><a href='http://www.pixelatom.com/php-performance-tip-3/' rel='bookmark' title='PHP Performance – Tip #3: Be careful with your loops'>PHP Performance – Tip #3: Be careful with your loops</a></li>
<li><a href='http://www.pixelatom.com/php-performance-tip-2-reduce-size-php-objects/' rel='bookmark' title='PHP Performance – Tip #2: Reduce the size of your PHP objects and be careful with static functions'>PHP Performance – Tip #2: Reduce the size of your PHP objects and be careful with static functions</a></li>
<li><a href='http://www.pixelatom.com/php-performance-tip-1-control-memory-usage-scripts/' rel='bookmark' title='PHP Performance &#8211; Tip #1: Control the memory usage of your scripts'>PHP Performance &#8211; Tip #1: Control the memory usage of your scripts</a></li>
</ol>]]></description>
				<content:encoded><![CDATA[<p>We are getting to the end of this series of <strong>performance tips</strong> and the most used performance tool could not be left out. We previously talked about loops, data structures, memory management, and even why we don&#8217;t consider that premature optimization is the root of all problem.</p>
<p>So lets get down to business and start taking of cache and how <strong><a href="http://linxphp.com.ar" title="LinxPHP PHP Framework">linxphp</a></strong> (the framework we are developing) implement this tool through <strong>SimpleCache</strong>.</p>
<p>I don&#8217;t think I should start taking about what is cache because I think it&#8217;s petty much obvious, instead let&#8217;s talk something more practical, how does it work:</p>
<p><em><strong>Cache is basically a pool of processed information that you know you will re-use</strong></em>. So instead of re-processing that information, you just pick it up from cache and use it. In programming there are a lot of situations that may require different considerations but in essence that is how cache is usually implemented.</p>
<p>In PHP development we have several ways of caching things, but the most used are: file system, database and the server memory. Other dirty solutions may include cookies or session variables but that&#8217;s not something I wish to talk about.</p>
<p>Lets consider cache using memory. Implementing a memory cache system usually involves some of third party tools like memcache, memcached, APC, etc. At least, these are the most used ones. But again, we should consider different cases because each engine has different capabilities.</p>
<p><strong>APC (Alternative PHP cache)</strong>: Is widely used because it&#8217;s present in most of LAMP environments. It lets you cache compiled php code in memory shared by all php requests of the same server</p>
<p><strong>Memcache or Memcached (checkout the difference)</strong>: Is, maybe, the most used cache system worldwide. Implements a distributed memory cache system across a set of one or more servers. It does not cache compiled code but it&#8217;s extremely useful for caching data structures and PHP objects in a memcache server cluster.</p>
<p><strong>File System:</strong> Is also largely used due to many shared hosting do not have memory caching features. So the principle is the same but using file system instead.  Is slower, of course, but is quite much cheaper regarding storage and yet quite effective. However you should take some considerations when using this type of cache because you have to control the TTL (Time to live) of each record cached, also you have to consider the way the structure is cached (serialized, json, etc).</p>
<p>If you are looking for a good library to implement different cache controls we recommend to use the one we develop for <strong><a title="Linxphp" href="https://github.com/Pixelatom/linxphp">linxphp</a></strong> called <a title="linxphp simplecache" href="https://github.com/Pixelatom/linxphp/tree/master/linxphp/core/cache/classes"><strong>simplecache</strong></a>, it has a main class that implements different cache engines which makes it quite versatile, you could take a look at <a title="linxphp" href="https://github.com/Pixelatom/linxphp/">github linxphp site</a></p>
<p>Lets see an example using <strong><a href="http://linxphp.com.ar" title="LinxPHP PHP Framework">LinxPHP</a> simplecache</strong>:</p><pre class="crayon-plain-tag">//simple cache set up
$cache_config = array('engine'=&amp;gt;'memcache');
simplecache::config($cache_config);
$starttime = microtime(true);
echo 'Memory usage before: ' .  number_format(memory_get_usage()). ' bytes &amp;lt;br&amp;gt;';
//cache key creation
$key = md5('SELECT * FROM table limit 1000');
//look for the cached content using the key
$result = simplecache::fetch($key);
//if no cache is stored make the query. If cache exists it will not execute the query.
if(empty($result))
{
    $pdo = new PDO (&quot;mysql:host=$host;dbname=$db&quot;,&quot;$usr&quot;,&quot;$pw&quot;);
    $statement = $pdo-&amp;gt;query('SELECT * FROM table limit 1000');
    $result = $statement-&amp;gt;fetchAll();
    //once having results from db, save cache using the key
    simplecache::store($key,$result,3600);
}
echo 'Process time: ' . (microtime(true)-$starttime) . ' ms &amp;lt;br&amp;gt;';
echo 'Memory usage after: ' .  number_format(memory_get_usage()). ' bytes &amp;lt;br&amp;gt;';
echo '&amp;lt;hr&amp;gt;';</pre><p></p>
<h3>Not Using Memcached</h3>
<p><strong>Memory usage before:</strong> 719,168 bytes</p>
<p><strong>Process time:</strong> 0.067841053009033 seconds<br />
<strong>Memory usage after:</strong> 27,326,432 bytes</p>
<h3>Using Memcached</h3>
<p><strong>Memory usage before: </strong>719,168 bytes<br />
<strong><br />
Process time: </strong>0.24466109275818 seconds <strong><br />
Memory usage after: </strong>27,393,272 bytes</p>
<p>As we can see, it is stupidly faster since you don&#8217;t have to make the query. Imaging having queries much bigger and heavier than this and then multiply that for thousands page requests of your site and you will understand how the high traffic pages can manage such demand (besides infrastructure).</p>
<p>However, it&#8217;s easy to over-use cache. Since it&#8217;s a great tool, many times it&#8217;s used for caching things it shouldn&#8217;t be cached. I&#8217;ve seen many bad implementations of cache and let me tell you it can give you quite a lot of headaches.</p>
<p>Just use common sense and do not stick with the only technology you know, keep learning. Then you even can have more than one working together. That is the case, for example, of having memcache for caching processed information and having file system cache to store generated HTML. That way you not only avoid hitting database but also generating HTML.</p>
<p>Ok, there are much more about performance but having in mind these tips, you will be waking the right path in terms of performance.</p>
<p>Of course, any feedback you may have about any of these posts it will very welcome.</p>
<p>Related posts:</p><ol>
<li><a href='http://www.pixelatom.com/php-performance-tip-3/' rel='bookmark' title='PHP Performance – Tip #3: Be careful with your loops'>PHP Performance – Tip #3: Be careful with your loops</a></li>
<li><a href='http://www.pixelatom.com/php-performance-tip-2-reduce-size-php-objects/' rel='bookmark' title='PHP Performance – Tip #2: Reduce the size of your PHP objects and be careful with static functions'>PHP Performance – Tip #2: Reduce the size of your PHP objects and be careful with static functions</a></li>
<li><a href='http://www.pixelatom.com/php-performance-tip-1-control-memory-usage-scripts/' rel='bookmark' title='PHP Performance &#8211; Tip #1: Control the memory usage of your scripts'>PHP Performance &#8211; Tip #1: Control the memory usage of your scripts</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://www.pixelatom.com/php-performance-tip-4-cache-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Performance – Tip #3: Be careful with your loops</title>
		<link>http://www.pixelatom.com/php-performance-tip-3/</link>
		<comments>http://www.pixelatom.com/php-performance-tip-3/#comments</comments>
		<pubDate>Tue, 28 Aug 2012 12:39:17 +0000</pubDate>
		<dc:creator>Elezeta</dc:creator>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[good practices]]></category>
		<category><![CDATA[loops]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.pixelatom.com/?p=362</guid>
		<description><![CDATA[It&#8217;s very common listening among php developers that premature optimization is the root of all evil. And in certain point makes some little sense. However, implementing good practices and having a good understanding of the language programming makes the difference between a standard developer and a good one. Why then don&#8217;t try to learn and write optimized [...]
Related posts:<ol>
<li><a href='http://www.pixelatom.com/php-performance-tip-2-reduce-size-php-objects/' rel='bookmark' title='PHP Performance – Tip #2: Reduce the size of your PHP objects and be careful with static functions'>PHP Performance – Tip #2: Reduce the size of your PHP objects and be careful with static functions</a></li>
<li><a href='http://www.pixelatom.com/php-performance-tip-1-control-memory-usage-scripts/' rel='bookmark' title='PHP Performance &#8211; Tip #1: Control the memory usage of your scripts'>PHP Performance &#8211; Tip #1: Control the memory usage of your scripts</a></li>
</ol>]]></description>
				<content:encoded><![CDATA[<p>It&#8217;s very common listening among php developers that <em><strong>premature optimization is the root of all evil</strong></em>. And in certain point makes some little sense. However, implementing<strong> good practices</strong> and having a good understanding of the language programming <strong>makes the difference between a standard developer and a good one</strong>. Why then don&#8217;t try to learn and write optimized code from the beginning? it could be extremely expensive getting aware your script is not optimized soon enough.</p>
<p>So, continuing with the previous series of <a title="Performance tips in PHP" href="http://www.pixelatom.com/php-performance-tip-2-reduce-size-php-objects/">performance tips</a>, today I&#8217;m going to talk about  the excessive use of loops. That means, before using a loop, just ask yourself 2 questions:</p>
<p><strong>1) Do I really need it? </strong></p>
<p>Even though the question sounds stupid for a senior developer, you may get surprised about how much programmers use unnecessary loops.</p>
<p><strong>2) Can I use a better way?</strong></p>
<p>In programming there&#8217;s always a different way of doing something. Just consider the best of the options.</p>
<p>Not convinced enough? Take a look at these examples that correspond to the previous questions.</p>
<p><span id="more-362"></span></p>
<h2>1) Try to avoid SQL queries within loops</h2>
<p>Have you ever tried to make a SELECT  mysql query within a while? I sure more than one of us did or saw something like this before. Well, let me tell you that&#8217;s an example of <strong>how not to do things</strong>.</p><pre class="crayon-plain-tag">$qry = mysql_query('SELECT * FROM one_table');
while ($result = mysql_fetch_all($query)){
    $qry2 = mysql_query('SELECT * FROM other_table WHERE id = '.$result['id']);
}</pre><p>This may work, yes. Could solve your problem?, yes. But you&#8217;re wasting resources. If you have some hundreds of visitors per day in your site, may be you never realized this is not optimized. But what if you make a paid ads campaign to your site and that number rises up to 2000 in a few hours?  Just pray the server goes fine.</p>
<p>So instead, use MySQL to work for you instead of PHP. Just use an INNER JON in something like this:</p><pre class="crayon-plain-tag">$qry = mysql_query('SELECT other_table.* FROM one_table INNER JOIN other_table ON one_table.id = other_table.id;');</pre><p>The difference using these example in my localhost with two tables of about 100 records used the following:</p>
<h4>First Example</h4>
<p>Memory usage before: 630,632 bytes<br />
Process time: 0.088531017303467 ms<br />
Memory usage after: 631,840 bytes</p>
<h4>Second Example</h4>
<p>Memory usage before: 631,840 bytes<br />
Process time: 0.022024869918823 ms<br />
Memory usage after: 631,840 bytes</p>
<h4>Conclusion</h4>
<p>As we can see, the second example work about 4 times faster than the single query. Even considering it was executed using example data is extremely important when you are right to the edge in high demand traffic sites.</p>
<h2></h2>
<h2>2) Consider using variables as reference</h2>
<p>Other things to have in mind, is that if you&#8217;re modifying an array within the loop, you should use reference. That way you don&#8217;t have to duplicate the data structure while pocessing the loop. I mean:</p>
<p>Do this:</p><pre class="crayon-plain-tag">foreach($array1 as $key=&amp;gt;&amp;amp;$value){
    $value = $value . '_ modified';
}</pre><p>Instead of:</p><pre class="crayon-plain-tag">foreach($array as $key=&amp;gt;$value){
    $array[$key] = $value . '_ modified';
}</pre><p>Look at the &#8220;&amp;&#8221; right before the variable $value. That means $value is the reference to the same position within the array and any change the variable suffers it will impact right into the array without duplicating the variable.</p>
<h4>First Example:</h4>
<p>Memory usage before: 6,489,680 bytes<br />
Process time: 0.0018508434295654 ms<br />
Memory usage after: 6,578,224 bytes</p>
<h4>Second Example</h4>
<p>Memory usage before: 6,578,224 bytes<br />
Process time: 0.0066568851470947 ms<br />
Memory usage after: 6,665,976 bytes</p>
<h4>Conclusion:</h4>
<p>The result is remarkable. The first example is like <strong>6 times faster</strong>. So seriously consider using references when using foreachs</p>
<h2></h2>
<h2>My Experience</h2>
<p><strong>Premature optimization IS NOT the root of all evil. </strong>Of course extremes are not good, but why not understanding the language you&#8217;re working on as deep as you can?. Consider the cost of having your business down because of not doing a good optimization. Just pay a little attention about how doing things and everything will go smoother.</p>
<p>Ok, that&#8217;s everything for This week, I hope you enjoyed the article. For the next one I will talk about the most needed tool when talking of web performance: <strong>Caching. </strong>Stay tuned</p>
<p>&nbsp;</p>
<p>Related posts:</p><ol>
<li><a href='http://www.pixelatom.com/php-performance-tip-2-reduce-size-php-objects/' rel='bookmark' title='PHP Performance – Tip #2: Reduce the size of your PHP objects and be careful with static functions'>PHP Performance – Tip #2: Reduce the size of your PHP objects and be careful with static functions</a></li>
<li><a href='http://www.pixelatom.com/php-performance-tip-1-control-memory-usage-scripts/' rel='bookmark' title='PHP Performance &#8211; Tip #1: Control the memory usage of your scripts'>PHP Performance &#8211; Tip #1: Control the memory usage of your scripts</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://www.pixelatom.com/php-performance-tip-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pixelatom video games II</title>
		<link>http://www.pixelatom.com/pixelatom-video-games-ii/</link>
		<comments>http://www.pixelatom.com/pixelatom-video-games-ii/#comments</comments>
		<pubDate>Sat, 25 Aug 2012 17:45:03 +0000</pubDate>
		<dc:creator>yogiri</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Pixelatom]]></category>
		<category><![CDATA[global game jam]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[HTML5 games]]></category>
		<category><![CDATA[indie games]]></category>
		<category><![CDATA[pixelatom]]></category>
		<category><![CDATA[video games]]></category>

		<guid isPermaLink="false">http://www.pixelatom.com/?p=311</guid>
		<description><![CDATA[Hello again, and welcome to the video games posts! Let&#8217;s continue with our short history. Nothing much happened between 2005 and 2009, when Pixelatom was born. Basically it was the first two guys plus Lucas Zallio, a guy who loved video games too! It was time to start again with the adventure. We began with [...]
Related posts:<ol>
<li><a href='http://www.pixelatom.com/pixelatom-video-games/' rel='bookmark' title='Pixelatom video games I'>Pixelatom video games I</a></li>
</ol>]]></description>
				<content:encoded><![CDATA[<p>Hello again, and welcome to the video games posts! Let&#8217;s continue with our short history.</p>
<p>Nothing much happened between 2005 and 2009, when Pixelatom was born. Basically it was the first two guys plus Lucas Zallio, a guy who loved video games too! It was time to start again with the adventure. We began with our developing routine (on our free time, as grown ups we had bills to pay now), but now Fenix was dead. But wait, a fenix (Spanish word for Phoenix) can not die, it is always reborn from its ashes: it was the turn for <a href="http://www.bennugd.org/" target="_blank">BennuGD</a>.</p>
<p>Bennu is the Egyptian name for fire bird, still a phoenix. As such, the language remained mostly untouched in syntax, but got several changes in the architecture. So the adventure continued with Bennu.</p>
<h3>Global Game Jam and HTML5</h3>
<p>But it wasn&#8217;t our only game developing tool this time! With the growth of the internet, Flash became the most popular platform for web games, and then HTML5. One of us got a copy of <a href="http://impactjs.com/" target="_blank">Impact JS</a>, a library to easily make Canvas and JavaScript games. At this point we were full time web developers, so the syntax was pretty familiar to us, and after several years without a finished game, we participated in the <a href="http://globalgamejam.org/" target="_blank">Global Game Jam 2011</a> with our SECOND finished game, this time made in 48 hours: <a href="http://games.pixelatom.com/poor-little-t-rex/" target="_blank">Poor little T-Rex</a>.</p>
<div id="attachment_374" class="wp-caption aligncenter" style="width: 492px"><a href="http://www.pixelatom.com/blog/wp-content/uploads/2012/08/poorlittletrex.png"><img class="size-full wp-image-374" title="poorlittletrex" src="http://www.pixelatom.com/blog/wp-content/uploads/2012/08/poorlittletrex.png" alt="Poor little T-rex" width="482" height="322" /></a>
<p class="wp-caption-text">Poor little T-Rex, our first HTML5 game.</p>
</div>
<p>The premise for the 2011 Game Jam was &#8220;extinction&#8221;, and we got into 3rd place in our city! Poor little T-Rex is a very simple game, where you have to run and jump avoiding the meteor shower and the pits. Also, you have to collect coins. We tried to use as much pixelart as we could, but since several artist did the elements separately the result was not as uniform as we wished. However, we were very happy with the result, the game was fun!</p>
<h3>Global Game Jam 2012</h3>
<p>The next year (I mean, this year, 2012) we participated again in the Global Game Jam. We finished our game within the 48 hours and, despite not having finished between the first places, we liked the final result. We felt like we were using well known elements in our previous game (a simple side-scroll platform), and we thought that we should experiment a little with new stuff; after all, this is the main objective of the Global Game Jam! So our entry for the 2012 edition was <a title="Hydro Jumper" href="http://games.pixelatom.com/hydrojumper/" target="_blank">Hydro Jumper</a>.</p>
<div id="attachment_375" class="wp-caption aligncenter" style="width: 588px"><a href="http://www.pixelatom.com/blog/wp-content/uploads/2012/08/hydrojumper.png"><img class=" wp-image-375 " title="hydrojumper" src="http://www.pixelatom.com/blog/wp-content/uploads/2012/08/hydrojumper.png" alt="Hydro Jumper" width="578" height="434" /></a>
<p class="wp-caption-text">Our second HTML5 game, Hydro Jumper.</p>
</div>
<p>The premise this year was a little more strange, since it was only a drawing of a snake eating itself called <a title="Ouroboros" href="http://en.wikipedia.org/wiki/Ouroboros" target="_blank">Ouroboros</a>. The game is a little bit complicated at first, but it gets challenging once you start understanding it. Basically you are in a spaceship and you have an energy bar. While not orbiting a planet, you drain energy from there. Once you get into orbit, a second bar appears, this is the &#8220;planet resources&#8221; bar. While orbiting the planet you drain its resources, but your energy bar gets filled slowly. Once you spot another planet, you must click on the screen when you feel like you can make a jump into the other planet orbit. This jump must be precise, otherwise you&#8217;ll crash into the planet, or you&#8217;ll not catch the gravity pull and then you&#8217;ll be sent into the emptiness of space.</p>
<p>Another point is that you can not stay too long in a planet. Once its resources are empty, the planet will explode and the game will end.</p>
<p>Well, that&#8217;s it for today. Remember that comments of any kind are welcome (except Viagra pills, I really don&#8217;t need that). In the next post I&#8217;ll get into our very first iOS game, made with BennuGD. Also, I&#8217;ll make a simple introduction about this multi-platform language, so you can make your own games with it.</p>
<p>Cheers!</p>
<p>Related posts:</p><ol>
<li><a href='http://www.pixelatom.com/pixelatom-video-games/' rel='bookmark' title='Pixelatom video games I'>Pixelatom video games I</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://www.pixelatom.com/pixelatom-video-games-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The road to linxPHP 2: Namespaces</title>
		<link>http://www.pixelatom.com/linxphp-2-namespaces/</link>
		<comments>http://www.pixelatom.com/linxphp-2-namespaces/#comments</comments>
		<pubDate>Fri, 24 Aug 2012 13:47:20 +0000</pubDate>
		<dc:creator>Javis</dc:creator>
				<category><![CDATA[LinxPHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Pixelatom]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[linxphp]]></category>
		<category><![CDATA[namespaces]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[pixelatom]]></category>

		<guid isPermaLink="false">http://www.pixelatom.com/?p=360</guid>
		<description><![CDATA[We are already working on the next version of our PHP framework called linxPHP, and I wanted to share with you guys a little bit of our thoughts and the experience we are acquiring when working on such particular project which requires a lot of reading and learning. One of the objectives of the version 2 [...]
Related posts:<ol>
<li><a href='http://www.pixelatom.com/php-5-4-traits/' rel='bookmark' title='PHP 5.4 Traits'>PHP 5.4 Traits</a></li>
<li><a href='http://www.pixelatom.com/linxphp-wrote-php-framework/' rel='bookmark' title='Linxphp and why I wrote another PHP framework'>Linxphp and why I wrote another PHP framework</a></li>
</ol>]]></description>
				<content:encoded><![CDATA[<p>We are already working on the next version of our PHP framework called <a href="http://pixelatom.github.com/linxphp/">linxPHP</a>, and I wanted to share with you guys a little bit of our thoughts and the experience we are acquiring when working on such particular project which requires a lot of reading and learning.</p>
<p>One of the objectives of the version 2  is to adopt a series of recommendations proposed by <a href="http://www.php-fig.org/">The Framework Interop Group</a>  (formerly known as the ‘PHP Standards Group’), in an effort to adhere to a common code style to make it easy for developers to use linxPHP with various other libraries for their projects, or even individual modules or linxPHP classes without needing to include the whole framework.</p>
<p>The first step is to adhere to the first recommendation, known as <a href="https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md">PSR-0</a>, which <em>aims to provide a standard file, class and namespace convention to allow plug-and-play code</em>.</p>
<p>So one of the big changes in the next version is the inclusion of <a href="http://www.php.net/manual/en/language.namespaces.rationale.php">PHP Namespaces</a>, all classes will have as top-level namespace  &#8221;linxphp&#8221;, and all of our modules will have a separate namespace, for example, the class FileCache will be under the namespace linxphp\Cache, the class Model would be under linxphp\Models and so on.</p>
<p>The requirements of the PSR-0 also  defines a set of rules for class autoloading:</p>
<ul>
<li>Each namespace separator is converted to a DIRECTORY_SEPARATOR when loading from the file system.</li>
<li>Each &#8220;_&#8221; character in the CLASS NAME is converted to a DIRECTORY_SEPARATOR. The &#8220;_&#8221; character has no special meaning in the namespace.</li>
<li>The fully-qualified namespace and class is suffixed with &#8220;.php&#8221; when loading from the file system.</li>
</ul>
<p>Below is an example function to demonstrate how the proposed standards would work with the PHP Autoload functionality:</p><pre class="crayon-plain-tag">&amp;lt;?php

function autoload($className)
{
    $className = ltrim($className, '\\');
    $fileName  = '';
    $namespace = '';
    if ($lastNsPos = strripos($className, '\\')) {
        $namespace = substr($className, 0, $lastNsPos);
        $className = substr($className, $lastNsPos + 1);
        $fileName  = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
    }
    $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';

    require $fileName;
}</pre><p>We&#8217;ll, actually, make use of this implementation to follow the autoloader interoperability standards, in the recommended way to load PHP 5.1 classes:</p>
<ul>
<li><a href="http://gist.github.com/221634">http://gist.github.com/221634</a></li>
</ul>
<p>Which is a much better solution, because it uses the <a href="http://www.php.net/manual/en/function.spl-autoload-register.php">spl_autoload_register </a>function (available since PHP 5.1), which allows to define different set of rules for autoloading depending on the implementation.</p>
<p>Below, an example of how to use the recommended implementation:</p><pre class="crayon-plain-tag">$classLoader = new SplClassLoader('Doctrine\Common', '/path/to/doctrine');
$classLoader-&amp;gt;register();</pre><p>This way 2 or more frameworks that follows these interoperability recommendations  can coexists in the same project, andwe want linxPHP to be one of them.</p>
<p>Until the next chapter of the road!</p>
<p>Related posts:</p><ol>
<li><a href='http://www.pixelatom.com/php-5-4-traits/' rel='bookmark' title='PHP 5.4 Traits'>PHP 5.4 Traits</a></li>
<li><a href='http://www.pixelatom.com/linxphp-wrote-php-framework/' rel='bookmark' title='Linxphp and why I wrote another PHP framework'>Linxphp and why I wrote another PHP framework</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://www.pixelatom.com/linxphp-2-namespaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Performance – Tip #2: Reduce the size of your PHP objects and be careful with static functions</title>
		<link>http://www.pixelatom.com/php-performance-tip-2-reduce-size-php-objects/</link>
		<comments>http://www.pixelatom.com/php-performance-tip-2-reduce-size-php-objects/#comments</comments>
		<pubDate>Thu, 16 Aug 2012 18:56:38 +0000</pubDate>
		<dc:creator>Elezeta</dc:creator>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[static]]></category>

		<guid isPermaLink="false">http://www.pixelatom.com/?p=320</guid>
		<description><![CDATA[Continuing with php performance tips post series I started last week, today I gonna talk about one of those things that directly impact into the performance of a PHP script specially when using frameworks When using frameworks we usually see how easy and practical is adding useful functions and attributes to the controllers and/or to the models [...]
Related posts:<ol>
<li><a href='http://www.pixelatom.com/php-performance-tip-1-control-memory-usage-scripts/' rel='bookmark' title='PHP Performance &#8211; Tip #1: Control the memory usage of your scripts'>PHP Performance &#8211; Tip #1: Control the memory usage of your scripts</a></li>
</ol>]]></description>
				<content:encoded><![CDATA[<p>Continuing with <a title="PHP performance tips" href="http://www.pixelatom.com/php-performance-tip-1-control-memory-usage-scripts/">php performance tips</a> post series I started last week, today I gonna talk about one of those things that directly impact into the <strong>performance of a PHP script</strong> specially when using frameworks</p>
<p>When using frameworks we usually see how easy and practical is adding useful functions and attributes to the controllers and/or to the models classes. However this is costly, specially setting attributes since these variables will make the object instance to be significantly bigger (in terms of memory consumption).</p>
<p>However, even though the functions you add to the PHP classes do not increase directly the memory usage of the instance, processor needs to compile every byte of that class and that cost memory.</p>
<p>So, <strong>consider to split the classes</strong> instead of having the mother of the controller and the grandfather of the models with every function related to the data processing. this way you can <strong>create separate clases that only be instantiated when needed</strong> instead of every time you want to execute a query.</p>
<p>Also, If you are dealing with huge arrays or huge objects and you have to pass them to a function, send the reference to the variable instead. This way <strong>the function won&#8217;t duplicate the variable in memory</strong> during execution.</p>
<p>One fun fact about working with objects is that <strong>static functions are less efficient than instantiating the class</strong> and calling the same method. Not sure why, but this is something to have in mind. Lets take this example:</p><pre class="crayon-plain-tag">class TestClass
{
   static function statictest($var){return $var;}
   function test($var) {return $var;}
}

echo '&amp;lt;strong&amp;gt;Static execution&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;';
echo 'Memory usage before: ' .  number_format(memory_get_usage()). ' bytes &amp;lt;br&amp;gt;';
$starttime = microtime(true);

for ($i = 0; $i&amp;lt; 100000000; $i++)
   TestClass::statictest($i);

echo 'Process time: ' . (microtime(true)-$starttime) . ' ms &amp;lt;br&amp;gt;';
echo 'Memory usage after: ' .  number_format(memory_get_usage()). ' bytes &amp;lt;br&amp;gt;';
echo '&amp;lt;hr&amp;gt;';

echo '&amp;lt;strong&amp;gt;Instanced execution&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;';
echo 'Memory usage before: ' .  number_format(memory_get_usage()). ' bytes &amp;lt;br&amp;gt;';
$starttime = microtime(true);

$obj = new TestClass();
for ($i = 0; $i&amp;lt; 100000000; $i++)
   $obj-&amp;gt;test($i);

echo 'Process time: ' . (microtime(true)-$starttime) . ' ms &amp;lt;br&amp;gt;';
echo 'Memory usage after: ' .  number_format(memory_get_usage()). ' bytes &amp;lt;br&amp;gt;';
?&amp;gt;</pre><p>This script outputs:</p>
<p><strong>Static execution</strong><br />
Memory usage before: 634,256 bytes<br />
Process time: 21.16055893898 ms<br />
Memory usage after: 634,680 bytes</p>
<hr />
<p><strong>Instanced execution</strong><br />
Memory usage before: 634,680 bytes<br />
Process time: 16.148050069809 ms<br />
Memory usage after: 635,192 bytes</p>
<p><strong>Instanced function was about 5 seconds faster using almost the same amount of memory!</strong> Funny huh?</p>
<p>Well that&#8217;s quite everything for this week. Stand by for the next tip, next week. As always, comments and feedback are welcome. Cheers!</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Related posts:</p><ol>
<li><a href='http://www.pixelatom.com/php-performance-tip-1-control-memory-usage-scripts/' rel='bookmark' title='PHP Performance &#8211; Tip #1: Control the memory usage of your scripts'>PHP Performance &#8211; Tip #1: Control the memory usage of your scripts</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://www.pixelatom.com/php-performance-tip-2-reduce-size-php-objects/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The confusion around Memcached PHP clients and their names</title>
		<link>http://www.pixelatom.com/confusion-memcached-php-clients-names/</link>
		<comments>http://www.pixelatom.com/confusion-memcached-php-clients-names/#comments</comments>
		<pubDate>Thu, 16 Aug 2012 13:01:23 +0000</pubDate>
		<dc:creator>Javis</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.pixelatom.com/?p=319</guid>
		<description><![CDATA[Once one starts to work with Memcached in PHP quickly realises that there are two very similar, but yet different, names around the subject, and it takes time and a lot of reading to realize what are the differences between Memcache and Memcached, and what these words means. First of all, one needs to know what [...]]]></description>
				<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-333" style="margin: 5px;" title="memcached-icon" src="http://www.pixelatom.com/blog/wp-content/uploads/2012/08/memcached-icon.gif" alt="" width="300" height="300" /></p>
<p>Once one starts to work with <a href="http://memcached.org/">Memcached</a> in PHP quickly realises that there are two very similar, but yet different, names around the subject, and it takes time and a lot of reading to realize what are the differences between <strong>Memcache</strong> and <strong>Memcached</strong>, and what these words means.</p>
<div>
<div>First of all, one needs to know what Memcached is:</p>
<blockquote><p>Free &amp; open source, high-performance, distributed memory object caching system.</p></blockquote>
<p>It&#8217;s a service running in the OS and can be accessed from many different programming languages. One of them, of course, is PHP. It&#8217;s name, then, it&#8217;s not &#8220;memcache&#8221;, it&#8217;s &#8220;memcached&#8221; what we&#8217;re using to store our values.</p>
<p>The problem resides in that there are 2 Memcached clients for PHP, the first one, called Memcache, and the newer called Memcached. The question here is who in his right mind would put these confusing names to the clients?! This becomes very annoying when searching on Google for help on how to use them, because they support different features and differs in many aspects, for example, Memcache supports native session handling in Memcached, but Memcached (the client) doesn&#8217;t. Already confused? Google too, it can not know when we are talking about the service, the old client or the newer one, for Google, everything is just &#8220;Memcached&#8221;, a word, and &#8220;Memcache&#8221;, probably a misspelling.</p>
<p>The situation gets worst when people confuse these terms and start writing Memcache as the service or Memcached to refer to the old client, which happen very often. If you&#8217;re starting to work with this technology, your head will mess all up until you get to  read a lot of web pages to realize why there are 2 different names and what is what.</p>
<p>So, I wanted to summarize all this to help the people who is running through the same problem:</p>
<ul>
<li><strong>Memcached</strong>: is the name of the Service running on the OS, and where we store the cache. It&#8217;s also the name of the newer PHP client library.</li>
<li><strong>Memcache</strong>: is the older Memcached client for PHP.</li>
</ul>
<p>Hope it helps!</p>
<p>Further reading:</p>
<ol>
<li><a href="http://serverfault.com/questions/63383/memcache-vs-memcached">An explanation of the names.</a></li>
<li><a href="http://code.google.com/p/memcached/wiki/PHPClientComparison" rel="nofollow">PHP Client Comparison</a>.</li>
</ol>
<p>&nbsp;</p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelatom.com/confusion-memcached-php-clients-names/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pixelatom video games I</title>
		<link>http://www.pixelatom.com/pixelatom-video-games/</link>
		<comments>http://www.pixelatom.com/pixelatom-video-games/#comments</comments>
		<pubDate>Wed, 15 Aug 2012 16:51:45 +0000</pubDate>
		<dc:creator>yogiri</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Pixelatom]]></category>
		<category><![CDATA[indie games]]></category>
		<category><![CDATA[video games]]></category>

		<guid isPermaLink="false">http://www.pixelatom.com/?p=296</guid>
		<description><![CDATA[Hello everybody, welcome to the fun part of the blog! I&#8217;ll start the video games posts by doing a quick review of the games we made so far. We&#8217;re still learning this cool art, so feedback, comments and insults are welcome! Origins Let&#8217;s start from our origins, initially we weren&#8217;t Pixelatom, but a small group [...]]]></description>
				<content:encoded><![CDATA[<p>Hello everybody, welcome to the fun part of the blog! I&#8217;ll start the video games posts by doing a quick review of the games we made so far. We&#8217;re still learning this cool art, so feedback, comments and insults are welcome!</p>
<h3>Origins</h3>
<p>Let&#8217;s start from our origins, initially we weren&#8217;t Pixelatom, but a small group of enthusiasts called AFSoft. This is, Arias and Fernandez, two of the current Pixelatom members. Under this name we started experimenting with an earlier DOS game programming environment called DIV Studio. We got a copy of DIV from a magazine and we really liked it. The year was 2001 if I remember correctly, and Javier Arias already made some progress writing a few small games (mainly shooters and a beat&#8217;em up). I&#8217;ll add a screenshot of one of those games later if I found one.</p>
<p>The problem with DIV Studio was that we needed a commercial license in order to publish games. As young students we didn&#8217;t had any money, let alone credit cards to buy a license from a Spanish company. Even worse, years later the company behind DIV disappeared! So what happened? Some guys started a similar project, with a free license to publish games: Project Fenix.</p>
<h3>Battle City Remake</h3>
<p>Under Fenix, we were able to continue our experiments, and decided to participate in a contest. As retro enthusiasts, we found about a Remakes community that organized yearly remakes contest: <a href="http://retroremakes.com/" target="_blank">Retro Remakes</a>. We got into the 2004 edition, and our entry, <a href="http://indiegames.com/2006/11/battle-city-remake.html" target="_blank">Battle City Remake</a> got the 21th place!</p>
<div id="attachment_297" class="wp-caption aligncenter" style="width: 586px"><a href="http://www.pixelatom.com/blog/wp-content/uploads/2012/08/battlecity.jpg"><img class=" wp-image-297  " title="battlecity" src="http://www.pixelatom.com/blog/wp-content/uploads/2012/08/battlecity.jpg" alt="Battle City Remake" width="576" height="432" /></a>
<p class="wp-caption-text">A screenshot of our first finished game, Battle City Remake</p>
</div>
<p>Battle City Remake was, as you might guessed, a remake of the classic Namco game for the NES and Nintendo Vs. System, <a href="http://en.wikipedia.org/wiki/Battle_City_(video_game)" target="_blank">Battle City</a>. Basically a one or two player coop game where you have to kill all 20 enemy tanks for every stage, taking care of not harming the base (marked with a quasi-eagle) trough 32 stages.</p>
<p>Graphics weren&#8217;t great, and we did mixed several techniques, but we were happy with the final result.</p>
<p>After that, our paths split for a few years, but we always kept our love for video game development. A few failed attempts here and there (that weren&#8217;t in vain, every small project gave us a lot of new knowledge!).</p>
<p>On the next post we will continue with our story as Pixelatom and our HTML5 games.</p>
<p>Until the next post!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelatom.com/pixelatom-video-games/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP 5.4 Traits</title>
		<link>http://www.pixelatom.com/php-5-4-traits/</link>
		<comments>http://www.pixelatom.com/php-5-4-traits/#comments</comments>
		<pubDate>Fri, 10 Aug 2012 13:00:39 +0000</pubDate>
		<dc:creator>Javis</dc:creator>
				<category><![CDATA[LinxPHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Pixelatom]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[inheritance]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[traits]]></category>

		<guid isPermaLink="false">http://www.pixelatom.com/?p=288</guid>
		<description><![CDATA[I&#8217;ve learned OOP in college with C++. This language has Multiple inheritance, which I found pretty handy by that time, and I got very used to it when doing OOP. When PHP finally implemented OOP in a decent way (PHP 5.1) I found that Multiple inheritance wasn&#8217;t allowed (I never fully understood why it&#8217;s said it&#8217;s a [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve learned OOP in college with C++. This language has Multiple inheritance, which I found pretty handy by that time, and I got very used to it when doing OOP.</p>
<p>When PHP finally implemented OOP in a decent way (PHP 5.1) I found that Multiple inheritance wasn&#8217;t allowed (I never fully understood why it&#8217;s said it&#8217;s a bad practice, I&#8217;ll let that to the Java boys) and I saw myself stuck in many situations where I needed it to do my classes the way I wanted to (interfaces are not actually the same, so can&#8217;t help some times).</p>
<p>So, that&#8217;s why I got very happy when I knew PHP 5.4 implemented <a href="http://php.net/manual/en/language.oop5.traits.php">Traits</a>.</p>
<blockquote><p>Traits is a mechanism for code reuse in single inheritance languages such as PHP. A Trait is intended to reduce some limitations of single inheritance by enabling a developer to reuse sets of methods freely in several independent classes living in different class hierarchies.</p></blockquote>
<p>In fact, Traits allows to recover the missing functionality of multiple inheritance in a simplified way. It&#8217;s basically a group of methods and properties that can be appended to any class.</p>
<p>Reading the php docs I found some good examples of traits, one of them is a really nice implementation of <a href="http://www.php.net/manual/en/language.oop5.traits.php#108293">singleton</a>, and the second one is a perfect <a href="http://www.php.net/manual/en/language.oop5.traits.php#107913">example</a> of when Traits are helpful in a case difficult to resolve with inheritance.</p>
<p>I&#8217;m really looking forward to implement them in the next version of our framework <a href="https://github.com/pixelatom/linxphp">linxphp</a>, as I know they will be really helpful on our Controllers and ORM classes design.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelatom.com/php-5-4-traits/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
