You are here: Re: Constructor as a "Reset" Button « PHP Programming Language « IT news, forums, messages
Re: Constructor as a "Reset" Button

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]


Удаленная работа для программистов  •  Как заработать на 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

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