Bastian Grupe wrote:
Blame my recent use of Java here ;-)
Well, I think the whole point of ppp is to having to use setters and
getters consistently.
i'm going to blame your use of Java for this one, ppp is way older
than the setter/getter fashion and as far as i remember the main
reason to introduce the setter/getter pattern into java was to
have a standard way for Java IDEs to provide access to Java Bean
properties in property dialogs in their GUI design tools
I personally wouldn't like to be able to access some members which are
private, and not others. It just *feels* wrong.
Think of it as a more fine grained permission system, like unix
file attributes. Reading and writing a property value are two
different operations and it makes sense to distinguish access
rights not only by ownership but also by type of operation.
And I don't know whether or not less typing is really a good argument in
this situation (think unreadable code in shortcut-ish programming
languages).
Less typing is not an argument by itself, else we'd all do APL
But less typing is less error prone (and no, plese *don't* mention
auto-completion here ;), it can be less readable, too, and in this
special case it spreads information that should be in one place.
Maintainability can become an issue, too.
Take a look at typical PHP class implementations: they have
all properties on top followed by the member functions. So to find
out whether a private property is really provite or whether it has
a getter or even a setter, too, i would have to browse the full
class code.
class example {
private $foo;
private $bar;
[... more properties ...]
function __construct() {...}
function __destruct() {...}
function getFoo() {...}
[... more code ...]
}
So $foo is readonly here and $bar is really private. Or wait,
maybe we have just overlooked getBar()?
With
readonly $foo;
on the other hand you have all the information in one place.
If you want to go the getter/setter path all the way then we
wouldn't need all the ppp stuff anymore alltogether, we would
just make everything private and have the getter and setter
decide (using instanceof on $this etc.) the access rights.
--
Hartmut Holzgraefe, Senior Support Engineer .
MySQL AB, www.mysql.com
Are you certified? http://www.mysql.com/training/certification
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php