News Feed
Sections
News Archive


Community Events






feed this:

SitePoint PHP Blog:
What's so bad about the Singleton?
0 comments :: posted Wednesday February 13, 2008 @ 12:13:00
voice your opinion now!

On the SitePoint PHP Blog today Troels Knak-Nielsen 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.

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 my post from last week, in which I present a way to avoid global symbols, without spending much time on why.

He talks about what they are and how they're commonly used - sometimes with some unpleasant side effects because of their use of globals.

tagged with: singleton designpattern global sideeffect static


Developer.com:
Threads Versus The Singleton Pattern
0 comments :: posted Friday June 01, 2007 @ 10:43:00
voice your opinion now!

In a new tutorial 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.

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.

They start with 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.

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.

tagged with: thread singleton designpattern tutorial thread singleton designpattern tutorial


mysql code database cakephp book developer zend PEAR pecl zendframework framework ajax conference security package job release application PHP5 releases

All content copyright, 2008 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework