News Feed
Jobs Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

DevArticles.com:
Singletons in PHP
December 06, 2011 @ 10:17:33

On DevArticles.com today there's a new tutorial posted talking about one of the more popular design patterns, the Singleton, and how it can be implemented in PHP.

Though in the past they enjoyed both popularity and a certain amount of prestige, without a doubt Singletons have progressively become one of the most evil and despicable villains in object-oriented design. Singletons earned their bad reputation for a reason: bringing them to life requires the programmer to deal at least with a static method. This is simply an elegant masquerade for creating a global access point (which in most cases is mutable as well) throughout an entire application. And we all know that global, mutable access is unquestionably a bad thing that must be avoided at all costs.

In this first part (of two) of the series they introduce the Singleton pattern and show how, via an example of using a database adapter interface to work with a MySQL database, in a tightly coupled example. In the second part of the series, they'll show how to break these apart using dependency injection.

0 comments voice your opinion now!
singleton designpattern dependencyinjection di mysql database adapter interface


blog comments powered by Disqus

Similar Posts

Zend Developer Zone: PHP Security Tip #19 (Securing Your Connection)

Adam Trachtenberg's Blog: PHP 5 + COM + Skype Help Wanted

Zend Developer Zone: The ZendCon Sessions Episode 7: High Performance PHP & MySQL Scaling Techniques

Paul Jones\' Blog: Fluent Interfaces Require Fluent Situations

Job Posting: WildCog Seeks Senior Database Engineer (San Francisco/Mountain View, CA)


Community Events











Don't see your event here?
Let us know!


security package symfony2 opinion language hack overview introduction facebook hhvm release dependency component install composer unittest framework podcast series application

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