News Feed
Sections




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

Brandon Savage's Blog:
Use Registry To Remember Objects (So You Don't Have To)
July 22, 2009 @ 07:52:35

Brandon Savage has posted a quick look at using one of the more popular design patterns - Registry - to handle object storage and retrieval.

One of the biggest challenges in OOP programming with PHP is the ability to pass around objects and let other objects use them. This challenge can be solved with careful design, however. Here we will discuss the registry pattern, not a member of the GoF's original patterns but still an important pattern nonetheless.

He looks at a few different ways to solve a few different problems - first, sharing a database resource between multiple objects, then making sure that you have a connection no matter where its called from and finally - what the registry is used for - sharing multiple database connections between multiple objects. He uses static methods in an abstract class to handle the set/get of the correct object.

There's also a bit of discussion about the registry pattern versus dependency injection and which is better for most instances.

1 comment voice your opinion now!
dependencyinjection registry designpattern


blog comments powered by Disqus

Similar Posts

DevShed: Handling Cookies and File Data with the Factory Pattern in PHP 5

DevShed: Object Interaction and Mediator Classes in PHP 5

Voices of the ElePHPant: Interview with Matthew Weier O’Phinney and Ralph Schindler

Michael Girouard's Blog: One Step Closer to an Abstract Singleton

PHPMaster.com: Logging with PSR-3 to Improve Reusability


Community Events





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


voicesoftheelephpant series api deployment podcast introduction interview symfony laravel install library tips package language release community list framework opinion bugfix

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