Re: how to mark protected properties?
| From: | Richard York | Date: | Tue, 08 Jun 2004 02:28:44 +0000 |
| Subject: | Re: how to mark protected properties? | ||
| References: | 1 2 3 4 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-30120@lists.php.net to get a copy of this message | ||
Stephan Schmidt wrote:
I like the inclusion of the '_', so far (with PHP 4) it has only been there really to alert to internal use of a property or method since there was no way to restrict access in the language itself. So I think that's what it should continue to mean in PEAR, whether the property or method actually be declared public, private or protected. I can think of some cases where I'd like to show that a property or method is only used internally, but not restrict access to it. On the other hand though I think that a method or property *specifically* declared private or protected should always be appended with an underscore, because in most cases these only exist for some sort of internal functionality, and again it makes those easier to spot in the normal flow of code whereas it would be optional on properties and methods declared public. In more verbose objects it would be more difficult to tell which properties or methods are only used internally. Of course this is not-with-standing employing some voodoo to make a protected member public, but, personally, I don't think that's the point of having the underscore anyway. The emphasis being not on the access privileges but on its existence being primarily or solely for internal use in the object. Just my .02 ;) Regards, Richard York -- ::::::::::::::::::::::::::::::::::::::::: The Spicy Peanut Project http://www.spicypeanut.net :::::::::::::::::::::::::::::::::::::::::I would say encapsulation is at least half the point of using OO in the first place, so I'd heartily agree with Bertrand. Everything should be private/protected and hence prefixing every var with '_' seems to make little sense.There's a rule for that: http://pear.php.net/manual/en/standards.naming.php At least private vars *must* be prefixed with an underscore. We should either remove that rule from the manual or follow the coding standards... I'm in favor of the first alternative, PHP5 is approaching, we will soon not need this anymore.