Re: how to mark protected properties?

From: Date: Mon, 07 Jun 2004 21:53:09 +0000
Subject: Re: how to mark protected properties?
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-30103@lists.php.net to get a copy of this message
Lukas Smith wrote:
Bertrand Mansion wrote:
-1 Everything should be protected by default in OO code. PHP makes everything public by default, that's just a design error and defeats the whole point of data encapsulation, probably due to BC. I won't prefix all my instance vars with _. Users are free to refer to the API documentation.
100% pure encapsulation is not efficient
Perhaps not, but accessing properties directly removes a huge amount of flexibility from application design -- by making requirements not only on the API of classes (for BC) but also the inner-workings of a class. 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. .02/Hans

« previous php.pear.dev (#30103) next »