Re: Properly handling multiple constructors.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Richard Quadling wrote:
On 24 March 2010 15:27, Robert Cummings <robert@xxxxxxxxxxxxx> wrote:
Are you asking a question? I'm not sure what you want here :) Does the
technique I sent provide you with a solution to this problem or not?

I can certainly see how your suggestion works.

And in my own code, I've often misused a method param list like this,
but that code never leaves my scratch area and is hardly ever
documented (ok, I'll be honest - there is nothing in the scratch area
which is documented!).

Does having static methods to funnel to the main constructor (which is
really always the complex one) make more sense here?

That way it is self contained and no need to have any misuse and no
additional classes.

	static function GetConnectorUsingKey($Key) {}
	static function GetConnectorUsingPartialData($Part1, $Part2, $Part3) {}
	static function GetConnectorUsingRules(Zend_Config $Rules) {}

each returning a new DataConnector().


This looks easy to understand. The main constructor doesn't need to be
hidden (GetConnectorUsingRules() is a static alias of __construct()).


All looks ok?

Yes you can do that also, you seemed to want constructors though :) As for misused... variable parameters with mixed types is common enough that I wouldn't call it misuse. It's succinct and solves a problem. Look at the printf() family of functions.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux