Re: RFC: C-sharp style property get/set syntax for PHP
| From: | president at basnetworks dot net | Date: | Thu, 02 Dec 2010 14:24:54 +0000 |
| Subject: | Re: RFC: C-sharp style property get/set syntax for PHP | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-50820@lists.php.net to get a copy of this message | ||
> president@basnetworks.net wrote:
>> I feel that the downfall of this syntax, is that the get and set methods
>> can easily be scattered at either end of a class definition. With the
>> syntaxes I provided, it is easy to tell which of the methods a property
>> has defined at a quick glance, because everything is in on spot.
>>
>> Additionally, public/private/protected/final/abstract/etc only has to be
>> specified once on the property (but can be specified separately! - see
>> the
>> RFC). This means less to read, and clearer, cleaner syntax.
>>
>> Lastly, I think that grouping the two methods just makes sense, because
>> a
>> property is one conceptual object, not two. Separating the two methods
>> makes as much sense logically as does separating a class definition into
>> two parts.
>>
>> - Dennis
> Grouping the get and set is a good convention. But grouping all the gets
> (doing
> pretty similar things) and all the sets can be as good as it. You would
> need to
> enter into each class/project to see which convention fits better.
Grouping all the gets and all the sets can already be done using __get and
__set. That is great when dealing with collections of data, but not good
at all for dealing with individual properties.
They are both meant for different situations, and I think would live quite
happily along side each other. Because of that, I think grouping the
get/set of an individual property is the best approach possible.
- Dennis