In practice, though, I have found that classwide methods make it hard to replace functionality by subclassing, because one needs to hardcode the package name everywhere its methods are called. Then, when subclassing the singleton package, one needs to replace all those calls to instead use the name of the subclass. Do you know if there's a way around this?
I think this is a shortcoming of using classwide methods. Where I work we now instead favor having Factory classes for producing singleton variables that we make available as "framework globals" as described in my earlier posting. This Factory class reads a configuration file in order to determine what kind of subclass it should instantiate, which works great for plug-and-play configuration of different installs of our application. Example:
As a convention we use all-caps for singleton variables.$FOO = FooFactory->get_foo();
In reply to Re: •Re: Avoiding global object handle
by gregorovius
in thread Avoiding global object handle
by Biker
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |