View Single Post
Old 01-21-2008, 11:48 AM   #2 (permalink)
xenon
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

Oh, come on...nobody uses it? Here's an example of how easy your life becomes:

index.php:
Code:
$database = new Database();

// ... some more code

require 'registry.php';
Registry::set( 'db', $database );
somelibrary.php (index.php dispatches this file):

Code:
require 'registry.php';

class Test
{
   protected $database;

   public function __construct()
   {
        $this->database = Registry::get('db');

        // do stuff with the db
   }
}
So, no more global declarations, no more passing through constructors/methods or such. Don't you think this is useful? Ok then, how about some other useful patterns you use and you think are worth delving into? (besides the Singleton of course)
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote