<?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>Wed, 19 Jun 2013 15:19:50 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[DZone.com: Factory patterns: Collaborators Map]]></title>
      <guid>http://www.phpdeveloper.org/news/18651</guid>
      <link>http://www.phpdeveloper.org/news/18651</link>
      <description><![CDATA[<p>
On DZone.com <i>Giorgio Sironi</i> has a new tutorial looking at <a href="http://css.dzone.com/articles/factory-patterns-collaborators">the Factory design pattern</a>, specifically the use of a "collaborators map" to create them inside of a dependency injection container.
</p>
<blockquote>
Like for every library, you should first evaluate if the costs and benefit of integrating [a dependency injection container] are worth it. The alternative is to write your own factory classes, methods and closures: this article explains one of the patterns for building dynamic Factory objects, and as such lowers the cost of the second option. What you know how to do has a lower cost than what you still have to learn, considering risk and implementation time.
</blockquote>
<p>
He talks about the "old way" of making your own factories to create objects and how the collaborators mapping can replace that. The collaboration mapping is passed in when the object is created and a "create" method is called when the objects (or sub-objects) are needed. He also mentions some of the "easy" and "hard" changes you could make to this setup to expand its functionality.
</p>]]></description>
      <pubDate>Wed, 24 Oct 2012 09:43:02 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: An Introduction to Dependency Injection, Service Locators & Factories (Part 1)]]></title>
      <guid>http://www.phpdeveloper.org/news/18120</guid>
      <link>http://www.phpdeveloper.org/news/18120</link>
      <description><![CDATA[<p>
On PHPMaster.com they've posted the <a href="http://phpmaster.com/managing-class-dependencies-1/">first part of a series</a> looking at something that's become a hot topic in the PHP community over the last months - dependency management and service locators.
</p>
<blockquote>
<p>
From a programmer's perspective, the process of designing easily consumable APIs while still keeping a decent level of decoupling between the involved classes is always a tricky trade-off, as the more expressive the dependencies are, the harder the work is that needs to be done behind the scenes for wiring up the collaborators in their proper sequence.
</p>
<p>
 In this two-part series I'll be doing a quick roundup of some of the most common methodologies that can be employed for managing class dependencies in modern application development, ranging from using service locators and injectable factories, to sinking your teeth into plain vanilla Dependency Injection, and even implementing a naive Dependency Injection Container.
</p>
</blockquote>
<p>
He talks about the "plague of the 'new' operators" and how, through the use of an injected factory object, they could be easily replaced. Code samples are included showing the initial state and the end result, refactored to inject his "SerializerFactoryInterface" into the "FileStorage" class.
</p>]]></description>
      <pubDate>Thu, 21 Jun 2012 08:59:15 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHP-Tip-a-Day: PHP Tutorial: The Allegory of The Factory Pattern]]></title>
      <guid>http://www.phpdeveloper.org/news/18081</guid>
      <link>http://www.phpdeveloper.org/news/18081</link>
      <description><![CDATA[<p>
On the PHP-Tip-a-Day site there's a new post from <i>Greg Bulmash</i> with an <a href="http://www.php-tip-a-day.com/php-tutorial-the-allegory-of-the-factory-pattern/">allegory about the Factory pattern</a> (design pattern) to relate it to something a bit more practical and introduce some of its core concepts.
</p>
<blockquote>
If you've read the <a href="http://www.php-tip-a-day.com/about-this-site/">About This Site</a> page, you'll know that instead of pursuing my passion for computers, I got sidetracked into the arts in college. So when it came time for me to learn and explain the <a href="https://www.ibm.com/developerworks/library/os-php-designptrns/#N10076">Factory Pattern</a>, I thought it might be fun to express it as an allegory...
</blockquote>
<p>
His example involves cars, axles and wood to illustrate how the Factory pattern lets you generate objects of different types automatically without having to worry about how they're created. He includes a code example in the form of an interface and a class that implements it (the "Axle" class). 
</p>]]></description>
      <pubDate>Tue, 12 Jun 2012 09:13:24 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Charles Sprayberry's Blog: DI and global state]]></title>
      <guid>http://www.phpdeveloper.org/news/17470</guid>
      <link>http://www.phpdeveloper.org/news/17470</link>
      <description><![CDATA[<p>
In response to some of the comments made on his <a href="http://phpdeveloper.org/news/17457">previous post</a> about why you should use dependency injection in your applications, <i>Charles Sprayberry</i> is <a href="http://cspray.github.com/2012/01/29/DI-and-global-state.html">back with some more concrete examples</a> showing how it all works with some code to back it up.
</p>
<blockquote>
To help better explain each of the three aspects of DI I discussed in the previous article I'll be going over each more thoroughly and with those code examples requested. I'll be going through each point one at a time as the explanations will likely be of some length compared to the original post.
</blockquote>
<p>
He starts with the "villain" of the story - the Singleton design pattern, a difficult to test method that lulls you into thinking you're not in the global scope. He talks about the problem of using this approach and how the <a href="http://sourcemaking.com/design_patterns/factory_method">Factory</a> design pattern can be used to create an alternative. He changes up the example to create a "DbTableFactory" class that can be used to create the objects needed - in this case a "UserTable" object with the connection injected into it at construct time.
</p>]]></description>
      <pubDate>Tue, 31 Jan 2012 09:24:47 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Understanding the Factory Method Design Pattern]]></title>
      <guid>http://www.phpdeveloper.org/news/17272</guid>
      <link>http://www.phpdeveloper.org/news/17272</link>
      <description><![CDATA[<p>
On PHPMaster.com today there's a new design pattern-focused that introduces you to using the <a href="http://phpmaster.com/understanding-the-factory-method-design-pattern/">Factory method</a> to create new objects on the fly.
</p>
<blockquote>
The Factory Method pattern is a design pattern used to define a runtime interface for creating an object. It's called a factory because it creates various types of objects without necessarily knowing what kind of object it creates or how to create it.
</blockquote>
<p>
Code is included showing how to make creating "Product_*" classes as simple as calling a "build()" method with the type. A slightly more complex situation is also included - building factories inside of factory methods. For more about the Factory design pattern, check out <a href="http://en.wikipedia.org/wiki/Factory_method_pattern">its Wikipedia page</a> (that includes some common uses and some pitfalls to watch out for).
</p>]]></description>
      <pubDate>Fri, 16 Dec 2011 12:15:54 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Play nice when extending Exception]]></title>
      <guid>http://www.phpdeveloper.org/news/16397</guid>
      <link>http://www.phpdeveloper.org/news/16397</link>
      <description><![CDATA[<p>
<i>Lukas Smith</i> <a href="http://pooteeweet.org/blog/0/1932#m1932">has a suggestion</a> for developers out there who get the idea to start messing with the order of the parameters of PHP objects/methods - play nice. His example is specifically with Exceptions.
</p>
<blockquote>
This is just a short follow up to a recent tweet of mine. I have seen this repeatedly happen, even to top notch and usually very careful developers (*). I am not sure why this mistake happens so frequently, but quite often you see code that changes the parameter order for custom Exception constructors. I guess it's mostly because in these cases the developer wants to pass some magic parameters that contain the message (and potentially also the code). 
</blockquote>
<p>
He recommends that, if you really do need to change something like the order of the parameters, use something like a <a href="http://en.wikipedia.org/wiki/Factory_method_pattern">factory</a> to handle the reorganization for you.
</p>]]></description>
      <pubDate>Mon, 30 May 2011 09:48:29 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Zend Developer Zone: Design Patterns I Hate]]></title>
      <guid>http://www.phpdeveloper.org/news/16354</guid>
      <link>http://www.phpdeveloper.org/news/16354</link>
      <description><![CDATA[<p>
On the Zend Developer Zone today there's a new post from <i>Keith Casey</i> about some of the <a href="http://devzone.zend.com/article/14938-Design-Patterns-I-Hate">design patterns he hates</a> - ones that are misused too often and have become more of a "worst practice" at times than others.
</p>
<blockquote>
To be clear, I think <a href="http://devzone.zend.com/article/14003-My-Favorite-Design-Patterns">Design Patterns have their place</a>. When used properly, they can make our lives easier and our code better. When they're misused - "<a href="http://en.wikipedia.org/wiki/Law_of_the_instrument">If the only tool you have is a hammer..</a>" - then they can become the bane of our existence. Unfortunately, some Design Patterns seem more susceptible to this than others. So maybe this is less "design patterns I hate" and more of "design patterns that have been abused beyond all sense of reason"... I'll let you decide.
</blockquote>
<p>
He has three of the most commonly misused design patterns in his list. Anyone who has looked into using patterns in their applications will recognize them:
</p>
<ul>
<li>Active Record
<li>Factory
<li>Singleton
</ul>
<p>
For each, he describes some of the bad implementations he's seen and notes that, while these are commonly abused, they can still be redeemed by being used appropriately.
</p>]]></description>
      <pubDate>Wed, 18 May 2011 10:18:21 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPBuilder.com: Using the Factory Pattern in PHP Applications]]></title>
      <guid>http://www.phpdeveloper.org/news/15963</guid>
      <link>http://www.phpdeveloper.org/news/15963</link>
      <description><![CDATA[<p>
On PHPBuilder.com today, there's a new tutorial posted about using one of the more well-known design patterns in your PHP applications - <a href="http://www.phpbuilder.com/columns//factory-pattern/Octavia_Anghel022311.php3">the Factory Pattern</a>. Design patterns are <a href="http://en.wikipedia.org/wiki/Design_pattern">repeatable methods</a> for doing common tasks in a "best practices" sort of way.
</p>
<blockquote>
In this article you will learn how to use the factory pattern design in your PHP application to construct different objects for interrogating a database (books) and displaying the records from a table (bookstore) [...] The essence of the factory method pattern is to "define an interface for creating an object, but let the subclasses decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses."
</blockquote>
<p>
He illustrates with a few sample scripts - one that displays a series of messages on factoried instances of a class, another that randomizes a display of images and another that handles book data and outputs the results.
</p>]]></description>
      <pubDate>Fri, 25 Feb 2011 10:07:37 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Label Media Blog: Design Patterns in PHP - Factory method]]></title>
      <guid>http://www.phpdeveloper.org/news/15501</guid>
      <link>http://www.phpdeveloper.org/news/15501</link>
      <description><![CDATA[<p>
On the Label Media blog today there's a new post from <i>Tom Rawcliffe</i> (the first part of a series) about a common design pattern you can use in your applications - <a href="http://www.labelmedia.co.uk/blog/posts/design-patterns-factory-method.html">the factory pattern</a>.
</p>
<blockquote>
A design pattern is a template used by software engineers as a guideline of how to solve a particular problem. [...] In this series of articles I plan to explore some of the design patterns that i have found most useful in my time as a PHP developer, providing examples and notes. So, this being the first, we'll take a look at the Factory Method Pattern.
</blockquote>
<p>
He defines the pattern - an interface to a class without the caller having to know what type of class it is - and a code example showing an abstract class with a "Factory" method that pulls information from either a jpeg or png class based on the extension of the file name given.
</p>]]></description>
      <pubDate>Fri, 26 Nov 2010 13:56:03 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[NETTUTS.com: A Beginner's Guide to Design Patterns ]]></title>
      <guid>http://www.phpdeveloper.org/news/14761</guid>
      <link>http://www.phpdeveloper.org/news/14761</link>
      <description><![CDATA[<p>
On NETTUTS.com today there's <a href="http://net.tutsplus.com/articles/general/a-beginners-guide-to-design-patterns">a new tutorial</a> that introduces a bit more advanced concept in the development process - design patterns.
</p>
<blockquote>
Design patterns are optimized, reusable solutions to the programming problems that we encounter every day. A design pattern is not a class or a library that we can simply plug into our system; it's much more than that. It is a template that has to be implemented in the correct situation. It's not language-specific either. A good design pattern should be implementable in most - if not all - languages, depending on the capabilities of the language. 
</blockquote>
<p>
They introduce a few of the more widely used patterns including the strategy pattern, adapter pattern, factory methods, decorator and singleton patterns. Each comes with a bit of code showing how it would work and a "where would I use this?" section with a better example.
</p>]]></description>
      <pubDate>Thu, 08 Jul 2010 08:47:55 -0500</pubDate>
    </item>
  </channel>
</rss>
