till wrote:
On 6/6/07, Brett Patterson <[EMAIL PROTECTED]> wrote:
Looks good. I do have a couple questions....
1.) You reference $GLOBALS everywhere. Doesn't an object have its own
scope, and thus requires that you declare the variable in the "global"
class scope to use it in the functions? Rather than using individual
function-specific $GLOBALS variables?
Yeah, in general you are correct - $GLOBALS is a superglobal (0)
though. It's a funky replacement for the current code since it makes
use of $GLOBALS too - all until we implement a backend, so it would be
(for example) $this->backend[$foo] .
So the class would start off with:
class rcRegistry
{
var $GLOBALS;
And then later in the functions you'd reference it with:
$this->GLOBALS['rcRegistry'] ...
That always depends! ;-)
Basically, we are looking to either implement a Singleton, or static
methods. If you use static methods (e.g. rcRegistry::set('foo', $bar))
we can not reference $this since it's not present in static.
Singletons have a little more runtime cost, but give you much greater
flexibility for expansion later. Thinking about your "pluggable backend"
idea, a singleton might be the way to go. The configuration file could
declare the type or factory for the singleton registry instance, so each
backend implementation just needs to extend the registry interface.
I may be completely off base, but that's just an impression.
Other than that, looks pretty good. Hopefully this will aid in moving
away from a config file, and more to holding config info in a database
which would be easier for admins to modify.
Yeah, I guess a basic configuration file is a must. But I totally
agree, the more database (whatever the backend may be), the easier to
manage. But it also makes you dependant on the database more and more.
Cheers,
Till
0,
http://de3.php.net/manual/en/language.variables.predefined.php#language.variables.superglobals
--
*Eric Stadtherr*
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>