01-21-2008, 11:48 AM
|
#2 (permalink)
|
|
The Frequenter
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
|
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.
|
|
|
|