|
Posted by Sanders Kaufman on 07/25/07 17:45
Michael Fesser wrote:
> .oO(Sanders Kaufman)
> Every experienced programmer will tell you that you should not do these
> things (of course you're free to ignore that). Calling a constructor in
> a way it's not meant to be called is just another point on that list.
There's nothing in the PHP documentation to indicate that calling this
public function this way is at all inappropriate.
>>> No, that's NOT the purpose of a constructor!
>> But that is how it works, and doing it that way does seem to simplify
>> the code.
>
> It _might_ work, but might also open a can of worms. You're calling for
> unpredictable results. If you like that, then go with your "simplified
> code".
There's nothing to indicate that calling the constructor will do
anything "unpredictable". Furthermore, as I'm testing the code, I find
that it works *exactly* as expected.
Beyond that, as Jerry pointed out, after the child (with its own
constructor) is created, it MUST manually call the parent's constructor
to get it to fire.
That's what made me realize that - regardless of what I've done with the
object, calling its public constructor returns it to a pristine state.
Navigation:
[Reply to this message]
|