<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Fri, 24 May 2013 13:24:17 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[PHPMaster.com: Reusing Implementation - a Walk-through of Inheritance, Composition, and Delegation]]></title>
      <guid>http://www.phpdeveloper.org/news/18229</guid>
      <link>http://www.phpdeveloper.org/news/18229</link>
      <description><![CDATA[<p>
On PHPMaster.com today there's a new tutorial posted that wants to <a href="http://phpmaster.com/reusing-implementation-a-walk-through-of-inheritance-composition-and-delegation/">provide a guide</a> to walk you through a trio of ideas to help with code/idea reuse in your applications - inheritance, composition and delegation.
</p>
<blockquote>
The popular belief is that reusing implementation, thus producing DRYer code, boils down to exploiting the benefits that Inheritance provides, right? Well, I wish it was that easy! [...] If you don't know what path to travel when it comes to reusing implementation, in this article I'll be doing a humble walk-through on the Inheritance/Composition/Delegation trio in an attempt to showcase, side by side, some of their most appealing virtues and clunky drawbacks.
</blockquote>
<p>
He starts off with a look at Inheritance, showing with a small code sample showing the creation of an interface and a resulting PDO adapter class implementing it. He also shows the concept of composition, following the ideas of the <a href="http://en.wikipedia.org/wiki/Adapter_pattern">Adapter pattern</a>. In his Delegation example he shows how to implement the creation of the connection object as a part of the class' creation.
</p>]]></description>
      <pubDate>Mon, 16 Jul 2012 11:42:54 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Bence Eros' Blog: Using Inheritance]]></title>
      <guid>http://www.phpdeveloper.org/news/15529</guid>
      <link>http://www.phpdeveloper.org/news/15529</link>
      <description><![CDATA[<p>
In <a href="http://erosbence.blogspot.com/2010/11/using-inheritance.html">this new post</a> to his blog, <i>Bence</i> looks at how inheritance is commonly used in PHP applications and how, if not controlled carefully can be something that creates bad habits among PHP developers.
</p>
<blockquote>
In fact I think that using inheritance all the time is a very big mistake and makes your code hard to maintain and more hard to integrate (the latter is a mistake for application codes and a fatal mistake for libraries). The main problem with inheritance is that if you use it for coupling two classes, then a very important property of the subclass is used up: it's superclass. It is taken, reserved, and it can not be used for anything else furthermore. If you want to connect your subclass to an other class using inheritance, you can't.
</blockquote>
<p>
He recommends avoiding the typical uses of typical superclass/subclass inheritance unless what you're doing specifically requires it. Working with interfaces, abstract classes and good composition planning is a much better idea.
</p>]]></description>
      <pubDate>Thu, 02 Dec 2010 12:14:39 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Devis Lucato's Blog: Anonymous objects in PHP - Composition, Mocks, Refactoring]]></title>
      <guid>http://www.phpdeveloper.org/news/15480</guid>
      <link>http://www.phpdeveloper.org/news/15480</link>
      <description><![CDATA[<p>
In <a href="http://lucato.it/php-anonymous-objects">a new post</a> to his blog <i>Devis Lucato</i> points out something he noticed when working with objects and anonymous functions/closures - they're not all as they seem.
</p>
<blockquote>
Both solutions allow to instantiate an anonymous object with properties. They are used as value objects and have no other purpose than storing values, so no logic can be included and they don't come with methods.  They can be used as function parameters instead of arrays, for instance. PHP 5.3.0 introduced anonymous functions and closures, so it is now possible to attach functions to these VOs (*). [...] The first thing to notice is that these properties are not methods but callable functions:
</blockquote>
<p>
In his example, an anonymous function dynamically appended to an object doesn't have access to a property set on the object just one line before. There's a way around it with <a href="http://php.net/call_user_func">call_user_func</a>, but it's not practical. His proposed solution is to create a type of Anonymous class that uses the __call method to catch the methods and translate them into calls to <a href="http://php.net/call_user_func_array">call_user_func_array</a> automatically. 
</p>]]></description>
      <pubDate>Tue, 23 Nov 2010 13:17:53 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Larry Garfield's Blog: Benchmarking magic]]></title>
      <guid>http://www.phpdeveloper.org/news/9005</guid>
      <link>http://www.phpdeveloper.org/news/9005</link>
      <description><![CDATA[<p>
<i>Larry Garfield</i> has <a href="http://www.garfieldtech.com/blog/magic-benchmarks">put together some benchmarks</a> based around a request he had from other developers (the "performance czars") as to how the magic functions in PHP5 would perform in the new environment.
</p>
<blockquote>
Already, there is talk of how, and if, to leverage PHP 5's object handling now that we don't need to deal with the weirdness of PHP 4's object model. Of course, because it's Drupal, our army of performance czars want to know just what the cost is for object handling, and especially advanced object magic like __get(), __call(), the ArrayAccess interface, and so forth.
</blockquote>
<p>
He an <a href="http://www.garfieldtech.com/blog/magic-benchmarks">his tests</a> on a Thinkpad (Intel Core2 Duo 2.2Ghz) running Kubuntu and PHP 5.2.3. They were run two million times benchmarking the different methods for:
<ul>
<li>function calls 
<li>__call
<li>__get
<li>__set
<li>iterators (array)
<li>inheritance
<li>composition
</ul>
<p>
His results are listed at the <a href="http://www.garfieldtech.com/blog/magic-benchmarks">end of the post</a>.
</p>]]></description>
      <pubDate>Thu, 08 Nov 2007 12:04:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Travis Swicegood's Blog: Why Inheritance Sucks]]></title>
      <guid>http://www.phpdeveloper.org/news/8826</guid>
      <link>http://www.phpdeveloper.org/news/8826</link>
      <description><![CDATA[<p>
<i>Travis Swicegood</i> has made two <a href="http://www.travisswicegood.com/index.php/2007/10/11/why_class_inheritance_sucks">blog</a> <a href="http://www.travisswicegood.com/index.php/2007/10/11/title_12">posts</a> about his agreement with other statements made about why class inheritance sucks.
</p>
<p>
From the <a href="http://www.berniecode.com/writing/inheritance/">original comments</a> made by <i>Bernard Sumption</i>:
</p>
<blockquote>
All of the pain caused by inheritance can be traced back to the fact that inheritance forces 'is-a' rather than 'has-a' relationships. If class R2Unit extends Droid, then a R2Unit is-a Droid. If class Jedi contains an instance variable of type Lightsabre, then a Jedi has-a Lightsabre.
</blockquote>
<p>
<i>Travis</i> <a href="http://www.travisswicegood.com/index.php/2007/10/11/why_class_inheritance_sucks">agrees</a> and then comes back with his <a href="http://www.travisswicegood.com/index.php/2007/10/11/title_12">second post</a> to clarify something - composition versus inheritance:
</p>
<blockquote>
I approach OOP from a flexibility standpoint with one of its biggest flex-points being loose coupling which in turn promotes reusability. I'm going to use Event as a hypothetical example.
</blockquote>
<p>
He uses Events and design pattern illustrations (like the Visitor and Observer) to help illustrate his point.
</p>]]></description>
      <pubDate>Fri, 12 Oct 2007 10:11:00 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Nefarious Designs: Object-Oriented PHP Part 2: Relationships]]></title>
      <guid>http://www.phpdeveloper.org/news/6100</guid>
      <link>http://www.phpdeveloper.org/news/6100</link>
      <description><![CDATA[<p>
Nefarious Designs has posted <a href="http://nefariousdesigns.co.uk/archive/2006/08/object-oriented-php-part-2-relationships/">part two</a> of their look at the object-oriented functionality, this time, there's a focus on the relationships objects and their friends have.
</p>
<blockquote>
<p>
Following on from my posts "Object-Oriented Concepts" and "Object-Oriented Javascript", I'm going to take a look at OOP in PHP.
</p>
In "Part 1: Definition" we took a look at defining objects and classes in PHP. In part 2 I'm going to look at the most important part of any object-oriented system - the relationships.
</p>
</blockquote>
<p>
They <a href="http://nefariousdesigns.co.uk/archive/2006/08/object-oriented-php-part-2-relationships/">look at</a> inheritance, association, aggregation, and references. Code examples are sprinkled liberally to help illustrate the points.
</p>]]></description>
      <pubDate>Mon, 21 Aug 2006 18:06:29 -0500</pubDate>
    </item>
  </channel>
</rss>
