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

Posted by Jerry Stuckle on 07/25/07 02:04

Sanders Kaufman wrote:
> Jerry Stuckle wrote:
>> Sanders Kaufman wrote:
>
>>>> If you want to "reset" the object, then you separate that out into its
>>>> own method and call it from the constructor -- similar to what you've
>>>> done with the Connect() method.
>>>
>>> It ain't good form to write redundant code.
>>> It's wasteful, inefficient, and is abhorrent to good OOP architecture.
>>> Indeed - the most powerful reason for using OOP is to be able to
>>> write a process once, and then to use it over and over and over, and
>>> in a variety of creative ways.
>>>
>>> Besides and again... my focus here is on not wasting resources
>>> unnecessarily.
>>
>> Read what he said. There is no redundant code.
>
> All the code I need to initialize and reinitialize my class is in the
> constructor.
>
> class baseclass {
> var $Database;
> var $ErrorMessage;
> var $RecordSet;
> function bvckvs_baseclass(){
> $this->RecordSet = array();
> $this->Database = new bvckvs_database();
> $this->ErrorMessage = $this->Database->ErrorMessage;
> return true;
> }
> }
>
> If I were to write a "reinit()" it would do exactly the same thing.
> How is that not redundant?
>

And it is incorrect to do it this way, and will eventually cause you
problems.

What happens, for instance, if PHP changes so that the base class
constructor is called automatically?

There is no replacement for good programming - and no excuse for sloppy
programming.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

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

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