Re: [PHP] Info into Class

From: Dan Ostrowski <dan(at)triad-dev(dot)com>
To: <gregm(at)3dcomputer(dot)com>, "[POSTGRES GENERAL]" <pgsql-general(at)postgresql(dot)org>
Subject: Re: [PHP] Info into Class
Date: 2002-09-03 17:02:01
Message-ID: 20020903110201.6f0eb26f.dan@triad-dev.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Absolutely. I can't stress this enough, as it's one of the major rules of
OO and has saved my arse several times. Even WITHIN the class, I use the
setX() methods over modifying $this->X = whatever, because you can
"intercept" those calls later on with minimal code change.

dan

On Tue, 3 Sep 2002 08:45:08 -0700
"Greg Martin" <gregm(at)3dcomputer(dot)com> wrote:

> The thing about PHP classes is that there are not many rules. It is
> usually suggested, as a matter of good practice to use get and set
> functions for your variables in classes in any language. A lot of
> people my think this is a bunch of extra work, but let's say you are
> keeping track of customers, and you are storing their phone number. If
> you write get/set functions for that variable, if later on you decide
> that you really need to be validating the phone numbers format, or
> getting a particular format out of the class you can easily add that
> code right in the get/set function and then that process only has to
> happen in one place, keeping your code nice and clean.
>
> greg
>
> -----Original Message-----
> From: Gerard Samuel [mailto:gsam(at)trini0(dot)org]
> Sent: Tuesday, September 03, 2002 6:45 AM
> To: php-gen
> Subject: [PHP] Info into Class
>
>
> Are there any rules as to how information from outside a class can be
> moved into it.
> What Ive been doing so far is
> 1. Through the constructor
> 2. defining a constant
> 3. Create a method whose sole purpose is to move data from the outside
> into the class.
> i.e.
> <?php
> class foo ()
> {
> ......
> function outside_data($bar)
> {
> $this->bar = $bar;
> }
> ......
> }
>
> // class constructor here
> .......
> $class->outside_data($php);
>
> ?>
>
> --
> Gerard Samuel
> http://www.trini0.org:81/
> http://dev.trini0.org:81/
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2002-09-03 17:09:56 Re: Where can I find more information of XML support in PostgreSQL?
Previous Message Bruce Momjian 2002-09-03 17:01:26 Re: to_char(0,'FM999.99') outputs 0.