Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread la...@garfieldtech.com
On 3/24/10 11:06 AM, Richard Quadling wrote: On 24 March 2010 15:51, Robert Cummings wrote: 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 prob

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Robert Cummings
Peter Lind wrote: On 24 March 2010 16:48, Robert Cummings wrote: But now Dalmation_construct1 isn't related Dog_construct1. This seems problematic from a design perspective unless I'm missing something in your proposal. As for abusing class semantics ... I don't see it. Using separate class

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Richard Quadling
On 24 March 2010 15:51, Robert Cummings wrote: > 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 func

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Peter Lind
On 24 March 2010 16:48, Robert Cummings wrote: > Peter Lind wrote: > > The ,... is a supported syntax. Then I'd add the appropriate docblock > for > the alternate constructors. It might be but in effect the documentation you're left with is vague and has double the a

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Robert Cummings
Richard Quadling wrote: On 24 March 2010 15:27, Robert Cummings 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 mis

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Robert Cummings
Peter Lind wrote: The ,... is a supported syntax. Then I'd add the appropriate docblock for the alternate constructors. It might be but in effect the documentation you're left with is vague and has double the amount of documentation lookups, to find out which parameters you can pass. Using a sep

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Richard Quadling
On 24 March 2010 15:27, Robert Cummings 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

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Peter Lind
On 24 March 2010 16:23, Robert Cummings wrote: > Peter Lind wrote: >> >> On 24 March 2010 16:09, Robert Cummings wrote: >>> >>> Peter Lind wrote: On 24 March 2010 15:33, Robert Cummings wrote: > > Peter Lind wrote: >> >> One of the main points of the OP was that you can

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Robert Cummings
Richard Quadling wrote: The following code (which cannot currently work as PHP does not allow for method overloading) would be perfect for me. __construct(registry::RetrieveViaKey(__CLASS__, $Key)); } /** * Constructor : Partial * * This constructor wi

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Robert Cummings
Peter Lind wrote: On 24 March 2010 16:09, Robert Cummings wrote: Peter Lind wrote: On 24 March 2010 15:33, Robert Cummings wrote: Peter Lind wrote: One of the main points of the OP was that you can document the code properly. Your example doesn't allow for nice docblocks in any way, as you

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Peter Lind
On 24 March 2010 16:09, Robert Cummings wrote: > > > Peter Lind wrote: >> >> On 24 March 2010 15:33, Robert Cummings wrote: >>> >>> Peter Lind wrote: One of the main points of the OP was that you can document the code properly. Your example doesn't allow for nice docblocks in any w

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Richard Quadling
The following code (which cannot currently work as PHP does not allow for method overloading) would be perfect for me. __construct(registry::RetrieveViaKey(__CLASS__, $Key)); } /** * Constructor : Partial * * This constructor will construct the rules fro

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Robert Cummings
Peter Lind wrote: On 24 March 2010 15:33, Robert Cummings wrote: Peter Lind wrote: One of the main points of the OP was that you can document the code properly. Your example doesn't allow for nice docblocks in any way, as you'll either have to param points or a whole lot of noise. I dunno,

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Peter Lind
On 24 March 2010 15:33, Robert Cummings wrote: > Peter Lind wrote: >> >> One of the main points of the OP was that you can document the code >> properly. Your example doesn't allow for nice docblocks in any way, as >> you'll either have to param points or a whole lot of noise. > > I dunno, seems h

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Robert Cummings
Peter Lind wrote: One of the main points of the OP was that you can document the code properly. Your example doesn't allow for nice docblocks in any way, as you'll either have to param points or a whole lot of noise. I dunno, seems highly documentable to me. Each route is handled by it's own m

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Robert Cummings
Robert Cummings wrote: Robert Cummings wrote: Richard Quadling wrote: Hi. I have a scenario where I would _like_ to have multiple constructors for a class. Each constructor has a greater number of parameters than the previous one. e.g. Factory method is probably the cleanest and simplest so

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Peter Lind
One of the main points of the OP was that you can document the code properly. Your example doesn't allow for nice docblocks in any way, as you'll either have to param points or a whole lot of noise. Quick note: __ prefixed functions are "reserved", you shouldn't use that prefix for any of your own

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Robert Cummings
Robert Cummings wrote: Richard Quadling wrote: Hi. I have a scenario where I would _like_ to have multiple constructors for a class. Each constructor has a greater number of parameters than the previous one. e.g. Factory method is probably the cleanest and simplest solution. Just pass an

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Nilesh Govindarajan
On 03/24/2010 05:58 PM, Richard Quadling wrote: On 24 March 2010 12:08, Nilesh Govindarajan wrote: On 03/24/2010 05:31 PM, Richard Quadling wrote: Hi. I have a scenario where I would _like_ to have multiple constructors for a class. Each constructor has a greater number of parameters than t

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Robert Cummings
Richard Quadling wrote: Hi. I have a scenario where I would _like_ to have multiple constructors for a class. Each constructor has a greater number of parameters than the previous one. e.g. Factory method is probably the cleanest and simplest solution. Just pass an ID as the first paramete

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Richard Quadling
On 24 March 2010 12:39, Peter Lind wrote: > And how exactly does that differ from building the same pizza in > different ways? Builder doesn't mean you have to create different > objects, it means taking the complexity in building a given object or > set of objects and storing it in one place. > >

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Peter Lind
And how exactly does that differ from building the same pizza in different ways? Builder doesn't mean you have to create different objects, it means taking the complexity in building a given object or set of objects and storing it in one place. In your case, it allows you to build your object in d

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Richard Quadling
On 24 March 2010 12:06, Peter Lind wrote: > Hmmm, that looks to me like you're trying to solve a problem in PHP > with a c/c++c/# overloading solution. I'd give the builder pattern a > try instead: http://en.wikipedia.org/wiki/Builder_pattern > > On 24 March 2010 13:01, Richard Quadling wrote: >>

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Richard Quadling
On 24 March 2010 12:08, Nilesh Govindarajan wrote: > On 03/24/2010 05:31 PM, Richard Quadling wrote: >> >> Hi. >> >> I have a scenario where I would _like_ to have multiple constructors >> for a class. >> >> Each constructor has a greater number of parameters than the previous one. >> >> e.g. >> >

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Nilesh Govindarajan
On 03/24/2010 05:38 PM, Nilesh Govindarajan wrote: On 03/24/2010 05:31 PM, Richard Quadling wrote: Hi. I have a scenario where I would _like_ to have multiple constructors for a class. Each constructor has a greater number of parameters than the previous one. e.g. Don't give specify any pa

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Nilesh Govindarajan
On 03/24/2010 05:31 PM, Richard Quadling wrote: Hi. I have a scenario where I would _like_ to have multiple constructors for a class. Each constructor has a greater number of parameters than the previous one. e.g. Don't give specify any parameters in the function declaration. Use helper fu

Re: [PHP] Properly handling multiple constructors.

2010-03-24 Thread Peter Lind
Hmmm, that looks to me like you're trying to solve a problem in PHP with a c/c++c/# overloading solution. I'd give the builder pattern a try instead: http://en.wikipedia.org/wiki/Builder_pattern On 24 March 2010 13:01, Richard Quadling wrote: > Hi. > > I have a scenario where I would _like_ to ha

[PHP] Properly handling multiple constructors.

2010-03-24 Thread Richard Quadling
Hi. I have a scenario where I would _like_ to have multiple constructors for a class. Each constructor has a greater number of parameters than the previous one. e.g. http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Enginee