<?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>Sat, 25 May 2013 10:22:59 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Pixelstech.com: Should we use Abstract class or Interface?]]></title>
      <guid>http://www.phpdeveloper.org/news/19478</guid>
      <link>http://www.phpdeveloper.org/news/19478</link>
      <description><![CDATA[<p>
On the Pixelstech.com site today there's a new post that talks about the <a href="http://www.pixelstech.net/article/1366044255_Should_we_use_Abstract_class_or_Interface_">differences between abstract classes and interfaces</a> and when's the best time to use either (or both).
</p>
<blockquote>
When we write programs, we may often get into a situation where we don't know whether we should use Abstract class or Interface when we want to define an abstract object. These two are very similar and they are interchangeable. On Stackoverflow, this question is asked many times, it's related to many programming languages. Also in the official documentation of PHP regarding the Abstract class and Interface, people are arguing about this. To understand this question, we need to understand their differences and use scenarios.
</blockquote>
<p>
They provide examples of abstract class and interface usage with one of the main differences being that you can define functionality in abstract classes. There's also examples showing classes that extend the abstract class while implementing the interface at the same time, helping to define the object structure to an even finer level.
</p>
Link: http://www.pixelstech.net/article/1366044255_Should_we_use_Abstract_class_or_Interface_]]></description>
      <pubDate>Thu, 18 Apr 2013 09:22:23 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[QaFoo Blog: Abstract Classes vs. Interfaces]]></title>
      <guid>http://www.phpdeveloper.org/news/18544</guid>
      <link>http://www.phpdeveloper.org/news/18544</link>
      <description><![CDATA[<p>
On the QaFoo.com blog <i>Kore Nordmann</i> shares some insight about the difference between <a href="http://qafoo.com/blog/026_abstract_classes_vs_interfaces.html">abstract classes and interfaces</a> and how they can be used effectively/correctly.
</p>
<blockquote>
Features of object oriented languages are often use from a purely technical perspective, without respect to their actual semantics. This is fine as long as it works for you, but might lead to problems in the long run. In this article I discuss the semantical differences between abstract classes and interfaces. I also outline why following the semantics of those language constructs can lead to better code.
</blockquote>
<p>
He defines "class" and "interface" before he gets too far into the differences, stating that a "class" is more of a "type" while an "interface" describes the type and the structure to use it. He also talks about how to tell them apart (when to use each). There's also some examples and "hints" to help you determine good and bad examples of interfaces and when an abstract class might be a better answer.
</p>]]></description>
      <pubDate>Tue, 02 Oct 2012 12:29:56 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Overriding Strategy Logic - The Template Method Pattern]]></title>
      <guid>http://www.phpdeveloper.org/news/18514</guid>
      <link>http://www.phpdeveloper.org/news/18514</link>
      <description><![CDATA[<p>
On PHPMaster.com there's a new tutorial posted talking about <a href="http://phpmaster.com/overriding-strategy-logic-the-template-method-pattern/">the Template Method Pattern</a> to help make some sense (and make easier to use) your implementation of the Strategy pattern.
</p>
<blockquote>
This bring us back to the question whether it's feasible to eliminate duplicated strategy logic via Inheritance rather than switching over to plain Composition. Indeed it is, and the clean up process can be conducted through an ubiquitous pattern known as <a href="http://en.wikipedia.org/wiki/Template_method_pattern">Template Method</a>. [...] Simply put, there's a base class (usually an abstract one), which declares a concrete method (a.k.a. the template) responsible for outlining the steps or hooks of a certain algorithm. Most of the time the base type provides boilerplate implementation for some of those steps and the remaining ones are delegated to subclasses.
</blockquote>
<p>
The subtypes then override the base's functionality and extend it with their own. They show an example of this by making a jQuery image slider (using <a href="http://jquery.malsup.com/cycle/">this plugin</a>) , an "AbstractCycleSlider" class and two subclasses for two other types - "FadeSlider" and "ScrollSlider", each outputting their own HTML. It also shows how to implement a slider using a <a href="http://www.zurb.com/playground/orbit-jquery-image-slider">different plugin</a> and output both in the same script.
</p>]]></description>
      <pubDate>Tue, 25 Sep 2012 08:58:01 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Subtype Polymorphism - Swapping Implementation at Runtime]]></title>
      <guid>http://www.phpdeveloper.org/news/18484</guid>
      <link>http://www.phpdeveloper.org/news/18484</link>
      <description><![CDATA[<p>
On PHPMaster.com there's a new tutorial from <i>Alejandro Gervasio</i> about <a href="http://phpmaster.com/subtype-polymophism/">subtype polymorphism</a>. It sounds a little scary, but really it's just a look at sub-objects that inherit from parents and how to swap them around at runtime to do different things.
</p>
<blockquote>
In this article I'll show you how to exploit the virtues that Polymorphism offers through the development of a pluggable cache component. The core functionality can be expanded later to suit your needs through the development of additional cache drivers.
</blockquote>
<p>
He starts off with the definition of an interface to provide structure to the sample application (the CacheInterface) and implements it in two different subtypes - a FileCache and an AppCache (using the file system and APC, respectively). He builds on these and creates a "View" that uses these caching systems to generate and save the output to a cache for use later in the execution.
</p>]]></description>
      <pubDate>Mon, 17 Sep 2012 12:48:52 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Refulz.com: Traits in PHP - Multiple and Nested Traits]]></title>
      <guid>http://www.phpdeveloper.org/news/18009</guid>
      <link>http://www.phpdeveloper.org/news/18009</link>
      <description><![CDATA[<p>
On the Refulz.com blog there's a new tutorial posted looking at <a href="http://php.refulz.com/traits-in-php-multiple-and-nested-traits/">traits (and nested traits) in PHP</a> including examples of them in use and how to create your own.
</p>
<blockquote>
Traits is a good new addition to PHP language. In our series about the <a href="http://php.refulz.com/series/new-in-php-5-4/">new features of PHP 5.4</a>, we reviewed the concept of Traits in PHP. The <a href="http://php.refulz.com/traits-in-php-5-4-introduction/">introductory article</a> talks about what the traits are and what is the general syntax of Traits in PHP. The second article attempts to explain <a href="http://php.refulz.com/traits-in-php-5-4-why-we-need-traits/">why we need traits</a>.
</blockquote>
<p>
The tutorial shows you how to define a custom trait use things like abstract methods, nesting them by making them "users" and how to use multiples at the same time (comma-separating).
</p>]]></description>
      <pubDate>Mon, 28 May 2012 15:16:29 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Sebastian G&ouml;ttschkes' Blog: Testclasses for symfony2]]></title>
      <guid>http://www.phpdeveloper.org/news/17815</guid>
      <link>http://www.phpdeveloper.org/news/17815</link>
      <description><![CDATA[<p>
<i>Sebastian G&ouml;ttschkes</i> has <a href="http://sgoettschkes.blogspot.com/2012/04/testclasses-for-symfony2.html">a new post to his blog</a> about a set of abstract base testing classes he's developed to help with the functional, unit and validation testing of his Symfony2-based applications.
</p>
<blockquote>
So, when developing with symfony2, I rely on my tests. They are my safety net and without them, I get a little nervous after every change. Does everything work? Did I forget anything? So I developed some classes which I extend. They work on top of PHPUnit and the symfony2 WebTestCase. The classes are used by my different types of Tests: UnitTests, ValidationTests, FunctionalTests (as well as IntegrationTests).
</blockquote>
<p>
Code for each type of testing base class is included in the post showing how he extends the based PHPUnit test case for unit testing and the Symfony WebTestCase for validation and functional testing. Each one of the classes are ready to use and give you some handy helper methods too. 
</p>]]></description>
      <pubDate>Fri, 13 Apr 2012 11:57:53 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Effects of Wrapping Code in Class Constructs]]></title>
      <guid>http://www.phpdeveloper.org/news/17320</guid>
      <link>http://www.phpdeveloper.org/news/17320</link>
      <description><![CDATA[<p>
DevShed has a new tutorial posted today looking to help you counteract the bad practice of <a href="http://www.devshed.com/c/a/PHP/PHP-Effects-of-Wrapping-Code-in-Class-Constructs/">wrapping procedural code in "class" constructs</a> and provide some useful suggestions of how to avoid it.
</p>
<blockquote>
Static helpers seem to be a great idea at first glance, as they're reusable components that don't require any kind of expensive instantiation for doing common tasks [...]. But the sad and unavoidable truth is in many cases they're simply wrappers for procedural code, which has been elegantly hidden behind a "class" construct. So what's wrong with this? Well, even in the most harmless situations, when you use a static helper that produces a deterministic output, you're actually throwing away the advantages that OOP provides.
</blockquote>
<p>
To illustrate, they create a basic validation class that can check for things like valid emails, float values, integers and URLs using PHP's <a href="http://php.net/filter_var">filter_var</a> function. They point out that the class is difficult to extend and that it is doing too many things to be correctly considered a "piece" of functionality. To correct the problem, they opt for a different approach - an abstract class acting as an interface to structure custom validators against. This provides set/get methods for things like the error message and value to evaluate. The implementation of the validators on top of this class is coming in the next part of the series.
</p>]]></description>
      <pubDate>Thu, 29 Dec 2011 10:06:58 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Building Concrete Validators]]></title>
      <guid>http://www.phpdeveloper.org/news/17293</guid>
      <link>http://www.phpdeveloper.org/news/17293</link>
      <description><![CDATA[<p>
On DevShed.com today there's the first part of a two-part series showing how to <a href="http://www.devshed.com/c/a/PHP/PHP-Building-Concrete-Validators/">build self-contained validator objects</a> that can be used to test the format of user input for validity.
</p>
<blockquote>
In this two-part tutorial, I show why the use of static helper classes can be detrimental to building robust and scalable object-oriented applications in PHP (though you should take into account that the concept is language agnostic). I also implement a set of instantiable, fine-grained validators, which can be easily tested in isolation, injected into the internals of other objects, and so forth.
</blockquote>
<p>
Their set of "concrete validators" are all based off of a validator interface/abstract class and check things like email formatting, floats, integers and URLs. Also included are a few examples of using the validators in a sample script.
</p>]]></description>
      <pubDate>Thu, 22 Dec 2011 11:24:25 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[XpertDeveloper.com: Abstract in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17055</guid>
      <link>http://www.phpdeveloper.org/news/17055</link>
      <description><![CDATA[<p>
On the XpertDeveloper.com site today there's a new tutorial talking about something that can not only help the structure of your application but can make things more reusable in the end - <a href="http://www.xpertdeveloper.com/2011/10/abstract-in-php/">abstract classes</a>.
</p>
<blockquote>
For Abstact keyword we can say that, abstract is type of the class and class which we can't create a object of it. Surprised???? [...] Abstract class can be used some what like an interface in PHP. So basically we can implement class using abstract. We can't extend more than one abstract class while we can implement more than one interface.
</blockquote>
<p>
They introduce you to the creation of an abstract class and show how to set up some abstract methods inside. These methods are required to be defined as a part of the extension in your class. One of the benefits they don't mention of abstract classes over interfaces is the ability to have methods in the abstract that are actual code, not just definitions of the structure (that's more of what <a href="http://us.php.net/interfaces">interfaces</a> are for).
</p>]]></description>
      <pubDate>Fri, 28 Oct 2011 09:55:07 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Ian Christian's Blog: Creating a custom form field type in Symfony 2]]></title>
      <guid>http://www.phpdeveloper.org/news/16725</guid>
      <link>http://www.phpdeveloper.org/news/16725</link>
      <description><![CDATA[<p>
<i>Ian Christian</i> has added a new post to his blog today showing how you can <a href="http://pookey.co.uk/wordpress/archives/286-creating-a-custom-form-field-type-in-symfony-2">create a custom form field type in Symfony 2</a> by extending the AbstractType.
</p>
<blockquote>
I am finally starting to dive into symfony 2 properly. Yes - it's taken a while, work has taken me in different directions! I found myself needing to create a custom form field type pretty quickly, but couldn't find much in the way of documentation to do so, so I thought I'ld throw it up here; partly to help others, but mostly to get feedback to make sure I'm not approaching this from the wrong angle.
</blockquote>
<p>
He includes the code that creates his custom "Person" model and the class to create his "transport type" select box that pulls in its values from a "choice list" class. He registers it in his bundle and it can then be included in his buildForm() method just like any other form field.
</p>]]></description>
      <pubDate>Tue, 16 Aug 2011 12:04:37 -0500</pubDate>
    </item>
  </channel>
</rss>
