[PW-dev] Widget factory
Status: Alpha
Brought to you by:
spadkins
|
From: James G S. <JG...@TA...> - 2001-06-11 18:41:23
|
Many of the examples have Widget -> method() for making a widget. I don't
think this is as good an idea as creating an instance of a factory class and
using that to create widgets.
In a threaded environment, we don't want to rely on globals for configuration
if the configuration might be different in different threads. This only might
come into play in a threaded Perl or in mod_perl 2.0. Not sure exactly how it
plays out, but better to be thread-safe just in case.
We might want two different configurations in one script. Not sure exactly
why, but better to allow it while not understanding why than to disallow
because we can't see a reason for allowing. There's no *good* reason (that I
can think of) for not allowing it.
Instead of:
$widget = Widget -> new("Widget::Type");
have
$controller = new Widget::Controller;
$controller -> state(new Widget::State);
# etc...
$widget = $controller -> widget("Type");
These are the reasons I went with an instance of Widget::Controller being the
factory in my development code instead of Widget -> method. Just thought I'd
throw it out there for possible discussion. :)
--
James Smith <JG...@TA...>, 979-862-3725
Texas A&M CIS Operating Systems Group, Unix
|