|
Posted by Jerry Stuckle on 07/25/07 02:09
Sanders Kaufman wrote:
> Jerry Stuckle wrote:
>> Sanders Kaufman wrote:
>
>>> That's ONE use for the constructor.
>>
>> As Andy said - that should be the ONLY USE for the constructor. If
>> you need to reinitialize the object, create a reinitialize() function.
>
> Why is that?
> It seems quite redundant.
>
Two different functions for two different purposes.
>
>> True. But it is the child class's responsibility to call the parent
>> class's constructor - which it should ALWAYS do. Other languages do
>> it automatically; PHP is lagging in this respect.
>
> In not real good about doing things just 'cause people keep saying
> "should" a lot. If I was, I'd be toting a 50 cal in Iraq, instead of
> drinking cappuccino in Dallas.
>
Then don't bother asking for any more advice.
>
>>> Furthermore, clsGrandKid can call that constructor any time it likes,
>>> and as often as it likes, returning gramma to a pristine state.
>>
>> 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.
>
> When I first started coding, a fellow named John Silver, here in Dallas
> gave me my first glimpse of OOP when he told me his rule of thumb: "If
> you find yourself performing the same procedure more than once, write a
> function and use that instead."
>
> It's GREAT advice and I haven't found a good reason yet to violate that
> rule - unless you count a couple of knowledgable, control-freaks who say
> that I "should".
Exactly. And we're not telling you do do that.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|