<?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>Thu, 04 Dec 2008 13:39:58 -0600</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[PHPFreaks.com: Design Patterns - Strategy/Bridge, Value Object, Singleton (Registry)]]></title>
      <guid>http://www.phpdeveloper.org/news/11183</guid>
      <link>http://www.phpdeveloper.org/news/11183</link>
      <description><![CDATA[<p>
Following up on their <a href="http://www.phpdeveloper.org/news/11174">introduction to design patterns</a>, the PHP Freaks have posted tutorials covering three of the more popular patterns - strategy/bridge, value object and singleton.
</p>
<ul>
<li><a href="http://www.phpfreaks.com/tutorial/design-patterns---strategy-and-bridge">Strategy and Bridge</a> - The Strategy and Bridge patterns provide solutions to apply polymorphism in more flexible way than you can accomplish with only inheritance.
<li><a href="http://www.phpfreaks.com/tutorial/design-patterns---value-object">Value Object</a> - The Value Object pattern has, just like the Singleton, to do with referencing and instances. In a way, the Value Object is the opposite of the Singleton: it's goal is to ensure NOT to use the same instance, under certain conditions.
<li><a href="http://www.phpfreaks.com/tutorial/design-patterns---singleton-and-singleton-registry">Singleton and Singleton Registry</a> - The Singleton pattern ensures that you are always dealing with the same, single instance, wherever in your application. The Registry pattern usually utilizes the Singleton pattern (hence "Singleton Registry") to make the same 'globalness' apply to objects who's classes weren't necessarily designed to
</ul>
<p>
Keep checking back to <a href="http://www.phpfreaks.com/tutorials">their tutorials section</a> for more design pattern tutorials.
</p>]]></description>
      <pubDate>Fri, 10 Oct 2008 09:33:10 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Eran Galperin's Blog: The Advancing PHP Developer Part 5: Design Patterns ]]></title>
      <guid>http://www.phpdeveloper.org/news/10595</guid>
      <link>http://www.phpdeveloper.org/news/10595</link>
      <description><![CDATA[<p>
As a part of his "Advancing PHP Developer" series, <i>Eran Galperin</i> has posted <a href="http://www.techfounder.net/2008/07/12/the-advancing-php-developer-part-5-design-patterns">part five</a>, a look at design patterns and what they can do for you and your application.
</p>
<blockquote>
A <a href="http://en.wikipedia.org/wiki/Design_pattern_(computer_science)">design</a> pattern is a general reusable solution to a recurring design problem in object-oriented systems. Design patterns are essentially blueprints that suggest how to solve a particular set of OO design problems while adhering to OO best good-practices (which I've recounted in my <a href="http://www.techfounder.net/2008/05/25/the-advancing-php-developer-part-2-object-orientation/">Object Oriented part of this series</a>).
</blockquote>
<p>
He talks about one of the most popular examples - the Model/View/Controller design pattern that is used in many rapid development frameworks for PHP (including CodeIgniter and the Zend Framework). He also briefly mentions a few others like the <a href="http://en.wikipedia.org/wiki/Composite_pattern">composite</a>, <a href="http://en.wikipedia.org/wiki/Singleton_pattern">singleton</a> and <a href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator</a> patterns.
</p>
<p>
Other parts of this series include looks at <a href="http://www.techfounder.net/2008/06/07/the-advancing-php-developer-part-4-testing/">testing</a>, <a href="http://www.techfounder.net/2008/05/27/the-advancing-php-developer-part-3-refactoring/">refactoring</a> and <a href="http://www.techfounder.net/2008/05/25/the-advancing-php-developer-part-1-coding-standards/">coding standards</a>.
</p>]]></description>
      <pubDate>Mon, 14 Jul 2008 09:32:26 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[SitePoint PHP Blog: What's so bad about the Singleton?]]></title>
      <guid>http://www.phpdeveloper.org/news/9624</guid>
      <link>http://www.phpdeveloper.org/news/9624</link>
      <description><![CDATA[<p>
On the SitePoint PHP Blog today <i>Troels Knak-Nielsen</i> asks th3e question "what's so bad about the singleton?" For all of its advantages, is there a darker side of the design pattern when it pertains to global variables.
</p>
<blockquote>
As I have often taken this stance myself, I found it reasonable that I should be able to argue for it, so I'll try to give an explanation. This is also in part a follow-up on <a href="http://www.sitepoint.com/blogs/2008/02/04/dealing-with-dependencies/">my post from last week</a>, in which I present a way to avoid global symbols, without spending much time on why.
</blockquote>
<p>
He <a href="http://www.sitepoint.com/blogs/2008/02/13/whats-so-bad-about-the-singleton/">talks about</a> what they are and how they're commonly used - sometimes with some unpleasant side effects because of their use of globals.
</p>]]></description>
      <pubDate>Wed, 13 Feb 2008 12:13:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Michael Girouard's Blog: One Step Closer to an Abstract Singleton]]></title>
      <guid>http://www.phpdeveloper.org/news/9122</guid>
      <link>http://www.phpdeveloper.org/news/9122</link>
      <description><![CDATA[<p>
<i>Michael Girouard</i> has <a href="http://www.lovemikeg.com/blog/2007/11/24/one-step-closer-to-an-abstract-singleton/">pointed out</a> that things in the PHP world are one step closer to being able to create an abstract Singleton object via a simple script he's shared.
</p>
<blockquote>
<p>
The singleton is an incredibly useful pattern in PHP for many reasons. I tend to find myself using them when I know I should be using static classes, but can't because of PHP's lack of proper class name discovery in extended static classes. 
</p>
<p>
[...] And that works like a charm every time. The problem is, in one application there may be several classes that need to be singletons. In which case my first thought was to build an abstract singleton.
</p>
</blockquote>
<p>
Unfortunately, it didn't quite work like he'd thought it would. He did, however, come up with something that did work - creating an interface and making an abstract implementation of it (code example for this included). 
</p>]]></description>
      <pubDate>Tue, 27 Nov 2007 09:37:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Make Me Pulse Blog: PHP 5 Design Pattern : Singleton]]></title>
      <guid>http://www.phpdeveloper.org/news/9094</guid>
      <link>http://www.phpdeveloper.org/news/9094</link>
      <description><![CDATA[<p>
On the Make Me Pulse blog today, <i>Antoine Ughetto</i> takes a look at one of the more handy things in programming - design patterns. He specifically <a href="http://blog.makemepulse.com/2007/11/22/php-5-design-pattern-singleton/">looks at the Singleton pattern</a> this time - complete with explanations and code examples.
</p>
<blockquote>
The singleton can be use in lot of different cases. In this example we will make a MySQL connection Singleton class. This will help us to always use the same connection.
</blockquote>
<p>
The code not only shows how to make the class using the Singleton but how to use it in your app - calling it with a SQL statement to make your request.
</p>]]></description>
      <pubDate>Thu, 22 Nov 2007 08:46:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Knut Urdalen's Blog: ORM the manual way]]></title>
      <guid>http://www.phpdeveloper.org/news/8547</guid>
      <link>http://www.phpdeveloper.org/news/8547</link>
      <description><![CDATA[<p>
<i>Knut Urdalen</i>, on seeing some of <a href="http://kore-nordmann.de/blog/why_active_record_sucks.html">the recent discussion</a> on why the ActiveRecord pattern sucks and <a href="http://www.urdalen.com/blog/?p=210">talks about</a> why, when presented with a the need for a database layer, he usually goes back to his own familiar Singleton-based style.
</p>
<blockquote>
I normally use a simple solution using the <a href="http://en.wikipedia.org/wiki/Singleton_pattern">Singleton</a> pattern for managing the database connection, the <a href="http://www.martinfowler.com/eaaCatalog/valueObject.html">Value Object</a> pattern for all business objects and the <a href="http://www.martinfowler.com/eaaCatalog/dataMapper.html">Data Mapper</a> pattern to manage the mapping between business objects and the database schema. It's as simple as that '" handcrafted and no magic going on.
</blockquote>
<p>
The <a href="http://www.urdalen.com/blog/?p=210">post also includes</a> his code for an example of a database connection - the creation of the Singleton interface class, making the Value Objects and customizing one for the type of "Product".
</p>]]></description>
      <pubDate>Wed, 29 Aug 2007 07:57:00 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Fernando Bassani's Blog: Avoiding the usage of global variables]]></title>
      <guid>http://www.phpdeveloper.org/news/8353</guid>
      <link>http://www.phpdeveloper.org/news/8353</link>
      <description><![CDATA[<p>
<i>Fernando Bassani</i> has <a href="http://fernandobassani.com/php/design-patterns/avoiding-the-usage-of-global-variables/">posted an alternative</a> to using globals in your scripts - creating "global objects" with the help of the Registry design pattern.
</p>
<blockquote>
For a long time, the "programming good practices" tell us to avoid globals. In fact, this is a point of a large criticism in languages such as PHP. A nice solution to our global's "needs" is the Registry <a href="http://en.wikipedia.org/wiki/Design_patterns">design pattern</a>. With it, we can have a repository with the data that has to be accessible, removing them from the global scope.
</blockquote>
<p>
Included in <a href="http://fernandobassani.com/php/design-patterns/avoiding-the-usage-of-global-variables/">the post</a> is all the code you'll need to get it to work. It uses a Singleton to grab the latest object and allows you to store values and define namespaces to keep data separate.
</p>]]></description>
      <pubDate>Mon, 30 Jul 2007 15:04:00 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Developer.com: Threads Versus The Singleton Pattern]]></title>
      <guid>http://www.phpdeveloper.org/news/7949</guid>
      <link>http://www.phpdeveloper.org/news/7949</link>
      <description><![CDATA[<p>
In a <a href="http://www.developer.com/design/article.php/3680701">new tutorial</a> on the Developer.com website today, they explore the difference between (and the benefits and disadvantages of) the singleton pattern versus threading in a PHP application.
</p>
<blockquote>
Although you probably could address some [of these] issues with the judicious use of synchronized blocks, do not overlook the utility of the ThreadLocal class. In this article, I will demonstrate the risk of not accounting for Threads when using a singleton pattern and show how simple it is to address.
</blockquote>
<p>
They <a href="http://www.developer.com/design/article.php/3680701">start with</a> the creation of a ThreadLocal class, one that allows the developer to communicate with the threads, and its usage. In contrast, they also create the Singleton class, showing the creation method of multiple objects of the same type.
</p>
<p>
They do, however, point out an issue that the threaded method has - unreliable results. Help is on the horizon, though, in the form of a HelperFactory class to manage the connections a bit more efficiently.
</p>]]></description>
      <pubDate>Fri, 01 Jun 2007 10:43:00 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Nick Halstead's Blog: Bad code, bad data flow, good idea?]]></title>
      <guid>http://www.phpdeveloper.org/news/7845</guid>
      <link>http://www.phpdeveloper.org/news/7845</link>
      <description><![CDATA[<p>
While developing a new application in a framework, <i>Nick Halstead</i> came across an "oops" point where he realized that the part of the application he was working on could have been coded better. In <a href="http://blog.assembleron.com/2007/05/14/bad-code-bad-data-flow-good-idea/">this instance</a>, he found a spot where he needed to pass data backwards and forwards through the app without loosing "the flow". His solution? Singletons!
</p>
<blockquote>
One of these situations occurs when you suddenly that find you don't have access to data you want, or you can't pass back (or forward) data as part of the common flow of your application. [...] The solution was to create a singleton class which uses references to bind a name to a already defined variable.
</blockquote>
<p>
In <a href="http://blog.assembleron.com/2007/05/14/bad-code-bad-data-flow-good-idea/">his example</a>, he illustrates (and explains) how to use a class he developed (varmap) to handle the assignment/removal/etc of the data to the common Singleton object.
</p>]]></description>
      <pubDate>Tue, 15 May 2007 09:28:00 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Tobias Schlitt's Blog: Avoid an endless pifall]]></title>
      <guid>http://www.phpdeveloper.org/news/7285</guid>
      <link>http://www.phpdeveloper.org/news/7285</link>
      <description><![CDATA[<p>
<i>Tobias Schlitt</i> has <a href="http://schlitt.info/applications/blog/index.php?/archives/523-Avoid-an-endless-pifall.html">provided a helpful hint</a> for developers working with lots of objects, methods, and singleton patterned functionality to keep out of the same trouble he faced.
</p>
<blockquote>
During my current exam phase I'm working on some tiny private project to relax after learning. In there I'm using a main controller class, which implements a singleton pattern and initializes several sub-controllers while being created. The singletons purpose is, that the other controllers can access to main controller and its functionality whenever they need, without storing a reference each.
</blockquote>
<p>
The problem with the code (he gives snippets) was a recursive loop that was suddenly appearing. He finally tracked it down to a constructor in another class that was accessing the main controller's constructor. The issue was that the constructor was never finishing up, so a valid instance wasn't returned, so the whole thing started all over again.
</p>]]></description>
      <pubDate>Thu, 15 Feb 2007 09:03:00 -0600</pubDate>
    </item>
  </channel>
</rss>
