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:
The Registry Pattern Reexamined
March 26, 2010 @ 12:57:04

Brandon Savage takes another look at a popular design pattern - the registry pattern - and how he's changed his thinking on its use a bit on how (or if) it should be used in your applications.

Last July, I wrote about the registry pattern and some of its advantages. These advantages include the ability to access objects across different areas of your application, and the storage of objects for later retrieval. [...] For me, over the last few months, I've discovered two reasons why I advise against the Registry Pattern: first and foremost, it discourages unit testing, and secondly, it discourages good design.

He goes on to elaborate on why these to things could be so detrimental to your code including the problems it can cause in tests being a point of failure and that it can make you application sloppy by giving you an unpoliced "bucket" to drop things in without any context to where they fit in the site.

So what's his suggestion to replace this bit of functionality and make things both easy to test and simpler to keep structured? Dependency injection.

3 comments voice your opinion now!
registry pattern unittest structure


blog comments powered by Disqus

Similar Posts

Felix Geisendorfer's Blog: Test Driven Development in Real World Apps

IBM developerWorks: Build seven good object-oriented habits in PHP

Michael Nitschinger's Blog: Understanding the Lithium Router - Part 2

Jani Hartikainen's Blog: Unit testing part 2: Writing and running tests

Artur Ejsmont's Blog: How to structure a Zend Framework application and it's dependencies


Community Events

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


php7 opinion series release interview voicesoftheelephpant extension laravel podcast list language framework example api laravel5 security version library community introduction

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