|
Posted by Rik on 07/25/07 02:32
On Wed, 25 Jul 2007 03:58:49 +0200, Sanders Kaufman <bucky@kaufman.net> =
=
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 architectur=
e.
>>> Indeed - the most powerful reason for using OOP is to be able to wri=
te =
>>> 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 =3D array();
> $this->Database =3D new bvckvs_database();
> $this->ErrorMessage =3D $this->Database->ErrorMessage;
> return true;
> }
> }
>
> 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 =3D 'bar';
}
}
//instantiating
$obj =3D new baseclass();
//altering
$obj->foo =3D 'foz';
//reinitializing
$obj->init();
-- =
Rik Wasmus
Navigation:
[Reply to this message]
|