[Solar-talk] Quick thoughts on new factory() method instantiation
Paul M Jones
pmjones at ciaweb.net
Mon Dec 11 15:38:14 PST 2006
On Dec 11, 2006, at 4:31 PM, Travis Swicegood wrote:
> In order to avoid possible conflicts inside Solar with other objects,
> there are a few options:
>
> 1. Create a "factory" property that if non-empty on an object would
> specify the name of the "factory" method to call
>
> 2. Use solar_factory() as the factory method that Solar::factory()
> calls
>
> 3. Use __factory() a teh factory method that Solar::factory() calls
>
>
> I like the looks of option three the best, but I'm not crazy about the
> possible confusion with the PHP level magic methods which have scoped
> out the double underscore as their namespace. Option one gives
> everyone
> the most flexibility, while option two seems to be the one that would
> allow the most standardization.
This is an excellent point, one I had not considered.
Of the options you present, my strongest aesthetic preference would
be __factory(), but that's way too close to PHP magic methods. As
you note, double-underscored function names are understood by
convention to be for PHP only to implement, so it's non-standards-
compliant to use that (rats!).
Of the remaining two, I like solarFactory() better. The property
idea seems a bit too loose, even for me.
Having said all that, can we talk about the specific implementation
issue you were running into? It may be that "factory()" (vice
"solarFactory()") is still viable.
--
Paul M. Jones <http://paul-m-jones.com>
Solar: Simple Object Library and Application Repository
for PHP5. <http://solarphp.com>
Join the Solar community wiki! <http://solarphp.org>
Savant: The simple, elegant, and powerful solution for
templates in PHP. <http://phpsavant.com>
More information about the solar-talk
mailing list