Reply to Re: Constructor as a "Reset" Button

Your name:

Reply:


Posted by Sanders Kaufman on 07/25/07 04:42

Rik wrote:
> On Wed, 25 Jul 2007 03:58:49 +0200, Sanders Kaufman <bucky@kaufman.net>


>> If I were to write a "reinit()" it would do exactly the same thing.
>> How is that not redundant?
>
> class baseclass{
> var $foo;
> function baseclass(){
> $this->init();
> }
> function init(){
> $this->foo = 'bar';
> }
> }

Yeah - I got that that's HOW to do it. That's easy.
I'm wondering WHY to do it.

The best answer came from Jerry when he said it was for purely academic
reasons - to keep tight with the OOP design principles.

And while I do want to keep it as OOPish as is feasible, I don't want to
introduce any extra functions that are not needed.

Since PHP4 (and apparently 5, as well) doesn't make the constructor a
private function, I don't yet see any reason to NOT use it as a
reset-switch for my object; to return it to a pristine state.

I did have a mild concern that it could result in something called a
Zombie process, or that resources would be locked that don't need to be,
but another poster assured me (and my experience confirms) that the PHP
garbage collection process is very efficient about not letting that happen.

[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

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