Reply to Re: Constructor as a "Reset" Button

Your name:

Reply:


Posted by Sanders Kaufman on 07/25/07 01:44

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.


> 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.


>> 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".

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация