Re: prototypes for getters and setters.
| From: | Alan Knowles | Date: | Wed, 13 Nov 2002 14:35:41 +0000 |
| Subject: | Re: prototypes for getters and setters. | ||
| References: | 1 2 3 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-90970@lists.php.net to get a copy of this message | ||
Actually looking at this in more detail, the solution PHP has infers that using $object->XXX='somevar' is heavily prefered over getXXX()/setXXX(), kind of against the grain for a classic OOP language (from the impressions have read), As refactoring (which is often the logic cited for setXXX()/getXXX() ) is handled by __getXXX() / __setXXX()
Obviously $object->XXX is going to be faster than $object->getXXX(), Would you say that the language design inherintly suggests you use $object->XXX. (and basically forget about getXXX() methods?)
Or can any think if there any other reasons why $object->XXX = 'yyy' is normally disuaded in classic OO design.. (and I'm not talking about private variables :)
Regards
Alan
Andrei Zmievski wrote:
On Wed, 13 Nov 2002, John Coggeshall wrote:I understand what your saying, however I guess I see the tradeoff of creating a new reserved word to a (IMHO of course) kinda messy new syntax a good one. Besides, having an absolute standard for get/set would be benefital to all developers.. Knowing that setting $foo is always setfoo() (or set_foo(), makes no difference) would be nice.We do have an absolute standard: __get() and __set().-Andrei http://www.gravitonic.com/* I wish life had an UNDO function. *